What is DBCC CHECKIDENT?
I had a post awhile ago about the LastId Dilemma – Resolved Finally. I used a DBCC command to check the seed value of an identity value, and then to “reseed” the seed value to a mush higher value to avoid the possibilities of duplicate key values.
So what are DBCC commands? DBCC stands for Database Consistency Checker. To get all the DBCC commands, do this:
DBCC HELP (‘?’)
I haven’t used many DBCC commands, except these two:
checkident: can be used to check and also re-seed values of an identity column
shrinkfile: I used to shrink SQL log files
Here are the examples:
backup log EAMPC with truncate_only
dbcc shrinkfile (EAMPC_log, 1)
DBCC checkident(myIdentityTable, noreseed)
DBCC checkident(myIdentityTable, reseed, 1000)