I need to create table with two columns. These columns have to be created with primary key. For example Column 1 name ID and column 2 name Name. ID is auto incremented. When data is inserted into the table, all names has to be different. How can I do that? Please help me.
To create the primary key:
ALTER TABLE dbo.YourTableNameHere
ADD CONSTRAINT PK_YourTable
PRIMARY KEY(ID, Name)
and to make sure the Name is unique:
ALTER TABLE dbo.YourTableNameHere
ADD CONSTRAINT UNIQUE_Name UNIQUE(Name)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With