SQL Server is recommended to restore the SQL code of the sequence number of the automatic Number Column

Source: Internet
Author: User
SQL Server is recommended to restore the SQL code of the sequence number of the automatic Number Column

SQL Server is recommended to re-restore the SQL code for the serial number of the auto-numbered Column

SQL server often has the following problems:
After a table uses columns with automatic numbers, tens of thousands of columns have been automatically numbered due to a large amount of data being tested. Now we are using this table, and the test data has been deleted. The legacy problem is that we are entering new data and the number will only be increased, deleted numbers cannot be used. Who knows how to solve this problem?

The truncate command not only clears all data, but also restores the SEED value of IDENTITY to the original value.

Dbcc checkident is more convenient. You can specify the SEED value without deleting data.
1. truncate table tablename
2. dbcc checkident (tablename, reseed, 1)

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.