Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Add constraint

Author  Topic 

SwitchNix
Starting Member

3 Posts

Posted - 2008-08-01 : 11:35:06
Hello,

With SQL Server 200 (management studio), I'd like to add a constraint to a field. I'd like a value must be unique for all record in the table. How can I do that via the GUI or/and by programming

Example : if you have a USER table the login field must be unique

Regards,

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-08-01 : 11:37:07
Did you check Books online before you post here? Books online comes with SQL server.
Go to Top of Page

SwitchNix
Starting Member

3 Posts

Posted - 2008-08-01 : 11:56:28
Yes but I didn't find what I want ...
Go to Top of Page

SwitchNix
Starting Member

3 Posts

Posted - 2008-08-01 : 12:02:29
Found :
ALTER TABLE [dbo].[TableName]
ADD CONSTRAINT CK_Name UNIQUE (FieldName)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-01 : 12:52:20
a simple search on google would have given you this link

http://doc.ddart.net/mssql/sql70/aa-az_5.htm
Go to Top of Page
   

- Advertisement -