You cannot add another primary key to table : Primary Key « Constraints « SQL Server / T-SQL Tutorial






5>
6> CREATE TABLE MyTable (
7>   MyID Int IDENTITY(1,1) NOT NULL , ID Int NOT NULL
8>  , Description nVarChar(50)
9>  , Region nVarChar(10) DEFAULT 'PNW'
10>  , CONSTRAINT MyTable_PK PRIMARY KEY NONCLUSTERED (MyID,Region))
11> GO
1>
2> ALTER TABLE MyTable
3> ADD CONSTRAINT PK_ID PRIMARY KEY NONCLUSTERED (MyID)
4> GO
Msg 1779, Level 16, State 1, Server J\SQLEXPRESS, Line 2
Table 'MyTable' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server J\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
1>
2> drop table MyTable;
3> GO
1>








7.2.Primary Key
7.2.1.Primary Key Constraint
7.2.2.The PRIMARY KEY Clause
7.2.3.Define constraint name for primary key
7.2.4.PRIMARY KEY (cust_id)
7.2.5.You cannot add another primary key to table
7.2.6.NONCLUSTERED PRIMARY KEY
7.2.7.Using a Multicolumn Primary Key