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 |
|
sj_rajesh
Starting Member
5 Posts |
Posted - 2005-03-25 : 01:18:19
|
| i have created a table and forgot to include the identity property to the column name "id" .i want to add that identity property to the exixting column "id". Can it be done through query analyzer?.If posible please give me the solution.thanksrajesh.RegardsRajesh.J |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2005-03-25 : 02:34:21
|
| The only way is to add NEW column (with identity property).And, optionally, to drop the OLD one (without this property). |
 |
|
|
SqlStar
Posting Yak Master
121 Posts |
Posted - 2005-03-25 : 04:37:16
|
| Why Microsoft is not giving this alter option? Any views??:) While we stop to think, we often miss our opportunity :) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-03-25 : 13:33:56
|
| Yes you can do this via Query Analyzer. But it isn't easy. What you should do is go into the design table option for the table in EM, highlight your column, type in Yes for the identity option at the bottom of the screen. Without saving it, click the icon that saves the change script. Copy that script into Query Analyzer and run it. What the script is doing is this:Create a temporary table with the structure that you wantMove the data to this tableDrop your tableRename the temporary table to your tableAdd constraints and indexes back inTara |
 |
|
|
SqlStar
Posting Yak Master
121 Posts |
Posted - 2005-03-28 : 05:51:52
|
quote: Originally posted by tduggan Create a temporary table with the structure that you want
Create a temporary table with the structure (Including Identity Column) that you want.:) While we stop to think, we often miss our opportunity :) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-03-28 : 12:43:18
|
| Well that would be why I said with the structure that you want.Tara |
 |
|
|
|
|
|