What does DBCC Checkident do?

What does DBCC Checkident do?

DBCC CHECKIDENT returns the current identity value and the current maximum value of the identity column. If the two values are not the same, you should reset the identity value to avoid potential errors or gaps in the sequence of values.

How can get current identity value in SQL Server?

Use IDENT_CURRENT() to Return the Current Identity Value on an Identity Column in SQL Server. In SQL Server, you can use the T-SQL IDENT_CURRENT() function to return the last identity value generated for a specified table or view on an identity column.

What is seed value in SQL?

The term seed refers to the internal value SQL Server uses to generate the next value in the sequence. By default, an identity column’s first value is 1 and each new value increments by one (1, 2, 3, 4, and so on). Once the table’s in production you can reset, or reseed the column.

When to use DBCC checkident in SQL Server 2017?

Checks the current identity value for the specified table in SQL Server 2017 and, if it is needed, changes the identity value. You can also use DBCC CHECKIDENT to manually set a new current identity value for the identity column.

When to reset DBCC checkident to maximum value?

If the current identity value for a table is less than the maximum identity value stored in the identity column, it is reset using the maximum value in the identity column. See the ‘Exceptions’ section that follows. DBCC CHECKIDENT ( table_name, RESEED, new_reseed_value ) Current identity value is set to the new_reseed_value.

How to check the identitiy of a column in DBCC?

The following operations can be performed with the DBCC CHECKIDENT command. The current identitiy value of an identity column can be found. The maximum identitiy value of an identitiy column can be found. The current identitiy value of an identity column can be set as any number.

What is the seed value in DBCC checkident?

In the above sql code if I use DBCC CHECKIDENT (myTable, RESEED,0) the identity column correctly starts from 1. The seed value is the value inserted into an identity column for the very first row loaded into the table.

https://www.youtube.com/watch?v=OtI8L0ZNCyE