Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

SQL Adding autonumbered primary key

Hi,

I have a table, and would like to add a new column which I would like autonumbered and used as a primary key

Thanks
0
BananaFury
Asked:
BananaFury
  • 2
1 Solution
 
Ross TurnerCommented:
Add an identity column

you can only have one identity column on a table...

http://msdn.microsoft.com/en-us/library/ms186775.aspx

here an quick example

http://sqlfiddle.com/#!3/6e601/1
0
 
BananaFuryAuthor Commented:
Thanks very much, that example is super useful, appreciated
0
 
Ross TurnerCommented:
Remember always take a BACK UP if you haven't already got one.....
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now