Solved

auto uniqueidentifier

Posted on 2007-11-20
3
255 Views
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?

Regards,
Joe
0
Comment
Question by:JoeBo747
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
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) )
go

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

select * from TestTab
0
 
LVL 143

Accepted Solution

by:
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
0
 
LVL 1

Author Comment

by:JoeBo747
ID: 20318889
Hi Angellll,

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

Regards'
Joe
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

622 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