June 25, 2004 at 9:45 am
Hello All
I have a rather simple question that Iseem to have trouble doing. I need to add multiple Pri Key to pre-existing columns in a table. Cna someone give the correct syntax for this?
Thanks in avance
June 25, 2004 at 10:32 am
You can only have one primary key on a table.
You need to check BOL for UNIQUE columns. There are probabaly what you are after.
June 28, 2004 at 2:10 pm
Although you can have only one PK, you can have multilple columns in your PK.
ALTER TABLE [dbo].[Table] DROP CONSTRAINT [TablePK]
GO
ALTER TABLE [dbo].[Table] ADD CONSTRAINT [TablePK] PRIMARY KEY CLUSTERED
(
[PK1],
[PK2]
  ON [PRIMARY]
GO
Signature is NULL
June 28, 2004 at 5:30 pm
You can also create multiple "Alternate" keys by using unique indexes.
Gary Johnson
Microsoft Natural Language Group
DBA, Sr. DB Engineer
This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply