Solved

SQL Server 2008

Posted on 2011-02-21
5
308 Views
Last Modified: 2012-05-11
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
Comment
Question by:murbro
5 Comments
 
LVL 18

Expert Comment

by:sventhan
ID: 34942154
0
 
LVL 16

Accepted Solution

by:
EvilPostIt earned 500 total points
ID: 34942209
int or bigint depending on how many records.

identity is a property.
0
 

Author Closing Comment

by:murbro
ID: 34942244
thanks very much
0
 

Expert Comment

by:Vivekvl
ID: 34942318
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
 
LVL 16

Expert Comment

by:EvilPostIt
ID: 34942340
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

733 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