Cannot update identity column & #39; XXX & #39;, identitycolumn

Source: Internet
Author: User

Cannot update identity column 'xxx', identitycolumn

Sqlserver -- how can I modify the id of the primary key to be updated manually?

#1 open the table Design Interface

#2 Change the is Identity attribute of the primary key id to No

In this way, you can use the Update statement to Update the table's primary key id.

How can I reset the auto-increment start value of the primary key id?

#1 command: dbcc checkident (tableName, reseed, 1000000)

#2 DBCC:

DBCC help ('? ') View all dbcc commands

Dbcc help ('checkdb') to view the details of a single command


Update table A set xxx = (select xxx from Table B where Axxx = xxx and Ayyy = yyy)

For example, you should not use the table name and field name in this logging interface. It is best to create an alias for the updated table,
However, this SQL statement is indeed good.

Data Change: Change multiple data entries Based on the id. Is one change or update tablename set XXX = xxx where id in (?)

In indicates that this statement processes a batch of data at the same time.
The efficiency of executing the update statement is much lower.
The results are the same, but note that the table is locked when the transaction is executed. Otherwise, others may operate on the table.

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.