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 2000 Forums
 SQL Server Development (2000)
 Identity

Author  Topic 

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2006-09-14 : 05:20:51
I have one table with Identity column in it. It contains 100 records.
now i wants to delete first 50 records and wants to maintain the Identity from 1 to 50 for last 50 records. so that whenever new record will be inserted in that table, identity will start from 51 and not from 101.

Thanks in advance,

Mahesh

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-09-14 : 05:27:43
for resetting the current identity you need to use

DBCC CHECKIDENT

Check in bol for more information

Chirag
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-09-14 : 05:49:08
You shouldn't rely on identities being sequential.
If you need the value to be sequential it is probably better to use another method otherwise you will have to check it continuously and update when there are missing values.

You can't update an identity value to to get the current rows starting from 1 you will have to delete them (copy to another table), set the identity seed and then insert them again.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -