Pages

Wednesday, September 2, 2009

Reseed Identity Column in a Table

Today in our web application we have to make a major release to production. Everything went fine but we have lot of test entries in the production. Our identity column of the User table increased from 1342 to 1456 because of the test entries. Myself and a friend of mine read an article for resetting the Identity Column. So after deleting the entries this is what you have to do.


Resetting Current Identity Value to New Value

use DBNAME

go
dbcc checkident(TABLENAME, reseed,seed value)

For Eg:

dbcc checkident(dbo.[User],reseed,1342)

which served my purpose.


To Get Current Identity Value

Also this seems to be useful. This gives the current identity value of the table.

use DBNAME

go
dbcc checkident(TABLENAME, noreseed)

For Eg:

dbcc checkident(dbo.[User],noreseed)

Please let me know your thoughts. Have a good day.

No comments:

Post a Comment