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.
| Author |
Topic |
|
chiragvm
Yak Posting Veteran
65 Posts |
Posted - 2011-11-15 : 08:25:12
|
| i have one table "emp"in table "emp_id" is a primary key ALTER TABLE dbo.Emp ADD CONSTRAINT PK_Emp PRIMARY KEY CLUSTERED ( Emp_id ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]now i want to add one more column in primary key how to add one more column in primary key with sintex |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2011-11-15 : 08:30:32
|
| Drop PK_Emp constraint first, and then recreate and include both required columns.ALTER TABLE dbo.Emp DROP CONSTRAINT PK_EmpALTER TABLE dbo.Emp ADD CONSTRAINT PK_Emp PRIMARY KEY CLUSTERED ( Emp_id, First_name ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]--------------------------http://connectsql.blogspot.com/ |
 |
|
|
chiragvm
Yak Posting Veteran
65 Posts |
Posted - 2011-11-15 : 08:38:23
|
| hello lionofdezertthanks for replay but is it mandatory to first delete current primary key constrain?bcoz i have already have fk for this table to other table |
 |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2011-11-15 : 09:34:13
|
| Yes you have to recreate it as there is no ALTER TABLE ALTER CONSTRAINT available :P--------------------------http://connectsql.com/ |
 |
|
|
|
|
|