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)
 reset identity column value

Author  Topic 

alexdcosta
Starting Member

12 Posts

Posted - 2006-11-08 : 17:30:01
I need to reset the value of a column of IDENTITY type with identity increment of 1 in SQL server 2000.

How can i accomplish this ?

Alex

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-11-08 : 17:36:34
Basically do this
DBCC CHECKIDENT(<tbl>,RESEED,0)

See DBCC CHECKIDENT in Books Online for details.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-11-08 : 17:40:21
"identity increment of 1"

If you mean you wan to resume with identity numbers allocated from 1 then as snSQL said.

if you mean that you currently have a NON-UNITY increment, and want the increment to be changed to be unity, then you need to use alter the current DDL for the table

Kristen
Go to Top of Page

alexdcosta
Starting Member

12 Posts

Posted - 2006-11-08 : 18:15:31
Currently, the value for my IDENTITY column is 12121

Now, year end is approaching, so i want to reset the value to 1.

How can i change this ??? ...........something like Alter sequence in Oracle.

Alex
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-11-08 : 23:14:38
You can use DBCC CHECKINDENT for that, but you can't reset to 1 if you are leaving existing rows in the table. If you want to start from 1 you'll need to delete existing rows (it's described in Books Online)

If you just want a new start value for the new year use DBCC CHECKINDENT to set it to a higher number like 100000.
Go to Top of Page
   

- Advertisement -