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 |
magmo
Aged Yak Warrior
558 Posts |
Posted - 2014-06-03 : 05:01:12
|
HiI need to add a identity, primary key with auto increment on a exsisting table, what would be the correct syntax to do that? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2014-06-03 : 08:01:04
|
[code]ALTER TABLE dbo.YourTableADD RowID INT NOT NULL IDENTITY(1, 1);GOALTER TABLE dbo.YourTableADD CONSTRAINT PK_YourTablePRIMARY KEY NONCLUSTERED ( RowID )WITH ( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON );GO[/code] Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
magmo
Aged Yak Warrior
558 Posts |
Posted - 2014-06-03 : 09:22:37
|
Excellent, thanks Peso! |
|
|
|
|
|