Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autonumber column 1

Status
Not open for further replies.

Penny001

Programmer
Feb 20, 2008
17
0
0
US
I created a SQL backend for a 2007 Access database using Microsoft 2008 SQL Server Management Studio Import/Export to load the existing Access tables. I noticed one of the fields in the Access table was an autonumber field. After it was imported into SQL - it was not autonumber.

How do you create an autonumber field in SQL?
 
In SQL Server, it's called an Identity column.

To make an existing column an Identity...

Open SQL Server Management Studio
In Object Explorer, on the left, drill down in to your table.
Right click the table, and click Design.
Click on the column you want to be an Identity
At the bottom of the window, you will see "Column Properties"
Scroll down and expand "Identity Specification"
Set (Is Identity) = Yes
You can change the Increment and Seed if you want to.

Increment is just that. How much to increment each value by. This is normally 1, but doesn't have to be.

Seed is the starting value. Again, this is normally 1, but doesn't have to be.


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top