• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

SQL Server 2008

Hi

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?
0
Murray Brown
Asked:
Murray Brown
1 Solution
 
EvilPostItCommented:
int or bigint depending on how many records.

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

Here is an excellent article on implementing sequence in SQL Server

http://blogs.msdn.com/b/sqlcat/archive/2006/04/10/sql-server-sequence-number.aspx

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.
0
 
EvilPostItCommented:
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.
0
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.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now