Solved

SQL Adding autonumbered primary key

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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 date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

705 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

14 Experts available now in Live!

Get 1:1 Help Now