SQL Server 2008


I am new to SQL. I have been developing in Access for quite a while.
What data type is best to use for an ID column that is the equivalent to AutoNumber
in Access?
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
EvilPostItConnect With a Mentor Commented:
int or bigint depending on how many records.

identity is a property.
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
thanks very much
Since you want equivalent to AutoNumber, going for sequence will be good option

Here is an excellent article on implementing sequence in SQL Server


Using sequence you can achieve literally the same feature as AutoNumber in Access. With little effort sequence can be customized to have prefix/suffix in alphabets

If you just want unique ID, NEWID() function is the easiest option available. This will not have readability and order.
For order issues with the NEWID function, i would suggest using NEWSEQUENTIALID function instead. This can cause massive problems with you clustered indexes if they are based upon this otherwise.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.