SQL Server 2005 Unique constraint on two columns -
How can you add a unique barrier to SQL Server 2005 in two columns? So I can say that I have:
PK, A, B ... x1 1 x x2 1 2 x3 2 1 x4 2 2
Should not I be able to add another line 'x5' and do the values for A and B be 1 because they are already in the database in X1?
Okay, we managed to work it out and thank you, God. Go to the Table view, select two columns, right-click and select 'Indexes / keys' - General tab, select the columns you want to make unique and then set 'Unique' to the right. This table is using the designer.
Thank you.
In SQL Server, use the unique barrier is actually implemented as a unique index :
create unique indexes & lt; Uix_name & gt; On & lt; Table_name & gt; (& Lt; col_A & gt;, & lt; col_B & gt;)
For more information, see.
Comments
Post a Comment