November 2, 2008 at 3:00 pm
Hi Friends
How do I add an Identity column to my existing table which has got over 1 million rows?
Thanks
November 2, 2008 at 3:52 pm
If you want it to be as fast as possible, you just add it to the end of the column list like this:
ALTER TABLE dbo.MyTable ADD
IDColumn int NOT NULL IDENTITY (1, 1)
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
November 2, 2008 at 3:54 pm
Note that this will still take some time (as it has to write to 1 million rows). And that it will have a big impact on your Log file (as you just wrote to 1 million rows).
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply