Solved

auto uniqueidentifier

Posted on 2007-11-20
3
252 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 142

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
migration MS SQL database to Oracle 30 63
SQL Help 27 48
MSSQL Import .SQL files - Increase Import Speed 9 44
average of calculation (TSQL) 4 11
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.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

825 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