Solved

SQL Adding autonumbered primary key

Posted on 2013-05-28
3
285 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
  • 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now