Wednesday, March 7, 2012

IDENTITY COLUMN QUESTION??

Hi
I am using VB.net/ASP.NET and SQL Server 2000 for a web application.

I have AccountNo as identity column. I use some dummy records for testing. But, every time I do a Delete from table and Insert Dummy rows, the identity Number of AccountNo starts for (Max(AccountNo)+1) of previously inserted rows. This throws of the AccountNo associated with my Dummy rows and actual table table rows.

How can I reset the IDENTITY to start from 1 without re-creating the table?

Please advice. Thanks in advance.

PankajTo my knowledge, you need to use TRUNCATE TABLE tablename to reset the identity value|||You can also use:

DBCC CHECKIDENT (authors, RESEED, 30)

where authors is the tablename and 30 is where you want to restart the IDENTITY. keep in mind that you will need to be aware of any potential conflicts in your data, such as if you are using the IDENTITY column as a primary key.

cs

No comments:

Post a Comment