SQL Server does not remove information restore the ordinal number of an AutoNumber column _mssql

Source: Internet
Author: User
This is often the problem with SQL Server:
After a table has an AutoNumber column, the number of automatic numbers has been accumulated tens of thousands, since testing a lot of data. Now it is time to use this table, the test data has been deleted, the remaining problem is in the entry of new data, numbering will only continue to increase, has been used but deleted numbers can not be used, who knows how to solve this problem?

The truncate command not only clears all the data, but also restores the identity's seed value to its original value.

DBCC CHECKIDENT is more convenient and can specify the value of the seed without deleting the data.
1. TRUNCATE TABLE TableName
2. DBCC checkident (tablename,reseed,1)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.