Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Set Identity Specification

Author  Topic 

d3ng
Yak Posting Veteran

83 Posts

Posted - 2009-01-29 : 22:18:37
Hi SQL experts,

I would like to ask for a SQL script on setting the IDENTIFY SPECIFICATION to YES and the identity increment = 1 and identity seed = 1.

Thanks in advance

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-29 : 23:24:17
You have to do that through Management Studio.
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-29 : 23:35:13
Hi,

Just drop the id column which is already existing and add a new column with same name id with identity property

For ex: create table temp1 ( id int, name varchar(50))
insert into temp1
select 1, 'abc' union all
select 3,'dsd'

select * from temp1

alter table temp1 drop column id

alter table temp1 add id int identity(1,1)
Go to Top of Page

d3ng
Yak Posting Veteran

83 Posts

Posted - 2009-01-30 : 01:10:33
Thanks. I just addedd some checking before executing the drop.
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-30 : 01:17:55
Welcome...
Go to Top of Page
   

- Advertisement -