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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you create an Autonumber in SQLServer? 3

Status
Not open for further replies.

clarkepj

Technical User
Aug 14, 2002
1
GB
I've imported a table from MS Access to a SQLServer 2000 database. However, the table had an Autonumber as the primary key & the DTS process has turned this field to a standard integer. Is there a way of changing this
datatype back to an autonumber so the table is in the same format as it was in MS Access?
 
No such data type as autonumber in SQL. What it uses instead is an integer field which is set as an Identity. IN Enterprise manager, look at your table design and click on this field. If you look at the bottom of the window there is an area which describes the details about that column definition. You will see that one of the options is Identity. It should say yes, if you want to Autonumber. If it says yes, you also need to specify the Identity seed and identity increment. The identity seed is just the number SQL would start numbering from if the table were empty. Since you have data it will start numbering from the last value unless the seed number was higher than the last value.
The identity increment is how many numbers it will increment each added record by. It is usually set to one.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top