Tuesday, January 27, 2015

constraint on text values in MSSQL

One may force the strings in a varchar column to be unqiue. This might be handy if the column contains the usernames for user accounts which should never to duplicates, etc. For an example of the SQL, this offers this:

ALTER TABLE MyTable WITH CHECK
ADD CONSTRAINT UQ_MyTable_Email UNIQUE (EmailAddress)

No comments:

Post a Comment