How to = "Remove the self-growth of the column without using sp_configure, and retain the original data

Source: Internet
Author: User

Scenario: Insufficient permissions (only one user, low privilege, cannot use sp_configure)

Perform

Appendix:

Update backupshopmenu set tempid=midalter table backupshopmenu drop column midexec sp_rename ' backupshopmenu.tempid ', ' MI d ', ' column ' ALTER TABLE backupshopmenu ALTER COLUMN MID int NOT null--If your auto is nullable then you don't need this paragraph.

Online reference:

How to remove the self-growth (identity) of a column with SQL statements

* * Cannot change existing self-increment field to non-self-increment by alter
For example, ALTER TABLE A alter ID int, the self-increment property will not be removed
You can do this by modifying the system table (this method may have unpredictable results, be cautious ...)
sp_configure ' allow updates ', 1
GO
Reconfigure with override
GO
Update syscolumns Set colstat = Colstat & 0x0000
where id=object_id (' table name ') and name= ' field name '
GO
sp_configure ' allow updates ', 0

---------------------------------------------
--A compromise approach
ALTER TABLE a add XXX int
Update a set Xxx=id
ALTER TABLE a drop column ID
exec sp_rename ' xxx ', ' id ', ' column '
---------------------------------------------

How to = "Remove the self-growth of the column without using sp_configure, and retain the original data

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.