In SQL Server, the identity identity column is often used, and this self-growing field is indeed more convenient to operate. But it sometimes brings some trouble.
Example one: when some data is deleted from the table, the number of the self-increment column is no longer a line-up sequence. At such times we can use the following solutions to solve.
SET Identity_insert [TABLE] [on| OFF] |
http://www.cnblogs.com/roucheng/p/GUID.html
Allows an explicit value to be inserted into the identity column of the table, when set to on, the number inserted into the identity column may be manually specified during the insert operation, and the identity_insert must be restored to off after the operation is complete, or the number must be specified the next time the insert is made. Otherwise, you will not be able to complete the insert operation.
Example two: when a record in a table is completely deleted, but when the value of the identity column becomes larger, it will grow indefinitely if not reset. This time we need to use:
DBCC checkident (TABLE, [reseed| Noreseed], [1]) |
The seed value of the specified table is reset to 1. However, you may not want to reset the seed to 1, in which case you can replace the third parameter with the seed value you want to use. Sometimes you may want to know the current seed, instead of resetting the seed, then you need to use the noreseed instead of worrying about the third argument.
Http://www.cnblogs.com/roucheng/p/earth.html
Identity identity Column