?
Solved

SQL Adding autonumbered primary key

Posted on 2013-05-28
3
Medium Priority
?
291 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 1000 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

777 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