auto uniqueidentifier

Posted on 2007-11-20
Last Modified: 2012-05-05
Hi Experts,

Is it possible to add an unique identifier in a SQL server 2005 table, I want the table to include a Key field called "ID" and this to auto increment by 1 for each new record, as autonumber in access?

Question by:JoeBo747
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20318792
yes, this is called an IDENTITY column.

create table TestTab (id int identity , name varchar(100) )

insert into TestTab select 'aneesh' union all select 'anoop'

select * from TestTab
LVL 142

Accepted Solution

Guy Hengel [angelIII / a3] earned 500 total points
ID: 20318795
add a column with data type int with the identity property set.
that will do the job

Author Comment

ID: 20318889
Hi Angellll,

I was using the wrong data type, thanks for the reply, thats what I needed.


Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Truncate vs Delete 63 90
sql query 7 35
Date conversion in sql server 2012 6 26
add 1 to a field for 100 rows 11 22
Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

760 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

19 Experts available now in Live!

Get 1:1 Help Now