Solved

SQL Server 2008

Posted on 2011-02-21
5
285 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

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now