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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Primary key constraint

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-03 : 08:38:22
Rekha writes "I have a table with many columns, two of them are Id and Name.
For The column "Id" i need to add primary key constraint and for the column "name" need to add unique key constraint with out dropping the columns.
Is this possible if so could U please send me the code snippet as well.

Thank U in advance"

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-06-03 : 08:55:19
Change [table1] to your table name

alter table [table1]
ADD CONSTRAINT PK_table1 PRIMARY KEY ([Id])
go

alter table [table1]
ADD CONSTRAINT UQ_table1_Name UNIQUE ([Name])
go

HTH
Jasper Smith

Go to Top of Page
   

- Advertisement -