The primary key in the SQL Server database automatically grows some special actions for the identity column

Source: Internet
Author: User

One. Turn off automatic identity column auto-growth:

The command required for the operation is: SET Identity_insert [table][on| OFF] After the parameter is "on", means: Open the Identity column manual insertion function. Once the command execution succeeds to insert data into the table thereafter, the automatic identity column will not grow automatically, and the contents of this column need to be inserted manually. Of course, after the data addition operation is completed, we need to turn on the "autogrow" function again, that is, the above statement is executed again, but the last parameter is replaced with "OFF", which means "Exit Identity manual Insertion function".

Two. Reset the value of the identity column to a value:

The commands required for the operation are: DBCC checkident (table,[reseed| NORESEED],[1]) Three parameters are required in parentheses, the first is the name of the table in which the identity column resides, the second is an optional two parameter, the type of operation (select "Reseed" is represented as "reset operation", and a third parameter is required to provide the value to be reset.) If you select Noreseed as the view operation, you do not need a third parameter at this point, and the third is the seed value of the identity column to reset to.

The primary key in the SQL Server database automatically grows some special actions for the identity column

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.