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 |
|
ndondo
Starting Member
1 Post |
Posted - 2009-08-13 : 15:00:45
|
| Hi all Here is my problem I have a table called ProductPackageit has 3 columns: ProductID, Quantity and PackageIDit has 1 PK: PK_ProductIDand I want to alter it to be look like this table: ProductPackage3 columns: ProductID, Quantity and PackageIDadd New column: ProductPackageID add new primary key: PK_ProductPackageIDbut when I do Alter Table ProductPackage ADD Column ProductPackageID Primary Key it comes up with an error because that table already have a primary key What I would like the sql to behave is like in SQL Studio management where I can right click and design. create column ProductPackageID then save it, then make ProductPackageID as Primary Key. SQL studio will move the primary key Icon from ProductID to ProductPackageID.so it's like a two step process. So what I want to know is How can I do that with a SQL query?Thank you |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-08-13 : 15:55:31
|
| Same way, make it a two step process:1. drop existing PK constraint2. alter table add new column as PKBe One with the OptimizerTG |
 |
|
|
|
|
|