Site icon Database Tutorials

DBCC CHECKIDENT in SQL Server(TSQL)

 

The following operations can be performed with the DBCC CHECKIDENT command.

First, we create a table with the help of the following script and add a few records into this table.

Find current and maximum identitiy value of an identitiy column:

Set an identity column’s current identity value to any number:

Set the Current Identitiy value as a lower number:

Let’s check the current and maximum identitiy again:

As you can see, Current identity value is 10 while maximum identity value is 12.

To set the current identity value of an identity column as the maximum identitiy value:

If the current identity value is smaller than the maximum identitiy value, we can set the current identitiy value as the maximum identity value as follows.

Check the current and maximum identitiy value again:

Exit mobile version