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 |
keyursoni85
Posting Yak Master
233 Posts |
Posted - 2012-08-10 : 01:58:12
|
I have table created and want to alter that table using script.I want to apply primary key and identity(1,1) using script.I can apply primary key but applying identity gives error. Is anything missing?ALTER TABLE MyTable ADD PRIMARY KEY (Id)How can I add identity as well with primary key? |
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2012-08-10 : 03:34:46
|
1- You cann't ALTER COLUMN for identity2- Primary Key can added with ALTER TABLE3- If need to add identity to existing column, copy your data to temp table (or other user table), drop orignal, recreate with identity changes and bring back you data.--------------------------http://connectsql.blogspot.com/ |
|
|
keyursoni85
Posting Yak Master
233 Posts |
Posted - 2012-08-10 : 04:20:29
|
yes.. got it thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|