The primary key is self-growing, but still prompts you cannot insert duplicate keys

Source: Internet
Author: User

Today the client side of the server was forced to shut down, and then the system is a problem, obviously self-growing columns but prompted not to insert duplicate keys

The following from the network,

SQL cannot insert duplicate key-the error primary key column is autogrow specifically described below:
Server: Msg 2627, Level 14, State 1, line 1
violated the PRIMARY KEY constraint ' pk_student '. You cannot insert a repeating key in the object ' Student '.
Statement has been terminated.

(I only use the second type to work) Cause: This error may be caused by an operation to the self-increment of the seed to the smaller, so insert when the report duplicate key error.
Solution: 1, directly on the database operation, cancellation of self-growth, plus self-growth, the seeds return to normal. However, this mode of operation if the database is larger, the error will be reported time-out, you can use the second solution, through the statement to complete.
2. Reset auto-Grow column seed: DBCC CHECKIDENT (' TB ', reseed, business table Max +1) The 3rd parameter is the Business Table autogrow column maximum of +1

The primary key is self-growing, but still prompts you cannot insert duplicate keys

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.