Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

auto uniqueidentifier

Posted on 2007-11-20
3
Medium Priority
?
260 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
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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

971 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