Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validate unique entry in a field
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01555897
Message ID:
01555901
Views:
32
>>Hi,
>>
>>I have a field in a table USER_ID CHR(20) which has to be unique for every record. I thought that if I default the value of this field to Null (make it Nullable) it would solve the problem where no value is assigned by user into this field. But SQL Server considers NULL a valid value and gives me "The duplicate key value is (NULL)". Does it mean that my only option to enforce this rule is in code? (Actually the code is VFP so it is not difficult but I want to know if there is another option).
>>TIA.
>
>If you're using SQL Server 2008 and up, you may want to go with the filtered index.
>
>http://aboutsqlserver.com/2010/09/12/sunday-t-sql-tip-uniqueness-of-nullable-field/
>
>http://social.msdn.microsoft.com/Forums/en/transactsql/thread/447b135e-3625-4d81-bacf-35122445256e

Thank you. I will look into this approach.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform