Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Validate unique entry in a field
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01555897
Message ID:
01555901
Vues:
31
>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform