Solved

SQL Adding autonumbered primary key

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AD and SQL Server 2016 2 25
First Max value 3 27
Run Stored Procedure uisng ADO 5 20
VB.NET Application Installation with sqlserver 8 28
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

839 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