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:
USE EAMPC
GO
backup log EAMPC with truncate_only
go
dbcc shrinkfile (EAMPC_log, 1)
go
DBCC checkident(myIdentityTable, noreseed)
go
DBCC checkident(myIdentityTable, reseed, 1000)
go