How SQL Server modifies the ID column, such as batch modification of the auto-incrementing Column

Source: Internet
Author: User

The interface is designed to be manual and cannot be used to modify thousands of servers in batches.
Because this script is executed in batches.
Environment: redgate + mssql 2008 r2
The following code is used when you modify your business.
Copy codeThe Code is as follows:
-- Allows updates to system tables.
Exec sp_configure 'Allow updates', 1
Reconfigure with override
GO
-- Unmark the ID column
Update syscolumns set colstat = 0 where id = object_id ('tablename') and colstat = 1
GO
-- Insert rows with id = 8001-8003
-- Restore the flag of an ID column
Update syscolumns set colstat = 1 where id = object_id ('tablename') and name = 'identify column name'
-- Reset the start value of the identifier
Dbcc checkident (Table Name, RESEED, 10003)
-- Update of system tables is prohibited.
Exec sp_configure 'Allow updates', 0
Reconfigure with override

There is also a lot of batch operation knowledge,
For example, check whether the index is accurate in batches.
Whether the field length is consistent
Whether the running result of the job is consistent
Whether the service is started at the same time
......
All must be processed in batches.
You can refer to other articles to obtain other batch operations.

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.