Solved

SQL Adding autonumbered primary key

Posted on 2013-05-28
3
288 Views
Last Modified: 2013-05-28
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
Comment
Question by:BananaFury
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Ross Turner earned 250 total points
ID: 39201099
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
 

Author Closing Comment

by:BananaFury
ID: 39201158
Thanks very much, that example is super useful, appreciated
0
 
LVL 7

Expert Comment

by:Ross Turner
ID: 39201174
Remember always take a BACK UP if you haven't already got one.....
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question