How to Solve problems in SQL with Identity






I was working with identity and i had found an problem and a solution to solve these kind of problems.


To see which number is on the identity column:

--
-- See what is the Identity in the table Articles
--
DBCC CHECKIDENT

(

articles


)
Response is:
Checking identity information: current identity value '6', current column value '6'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

To setup with a new number on the identity column

DBCC CHECKIDENT

(

articles,reseed ,6000


)

it returns

Checking identity information: current identity value '1000', current column value '6000'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

Note:
Don´t use truncate to delete table records it´s faster but it resets the identity column use instead the delete statement

No response to “How to Solve problems in SQL with Identity”

Post a Comment