Home > SQL Challenge > What is DBCC CHECKIDENT?

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:

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

Categories: SQL Challenge
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: