Alter table image alter column ID int identity (1, 1) not null help me see if the statement is correct !!

Source: Internet
Author: User

alter table image alter column ID int identity (1, 1) not null
I can only query analyzer, so this is the only option, the system prompts an error. How can this problem be solved ??

================================================= ================< br> you cannot directly change it to an ID column:
you can add a new ID column, set the ID column to be allowed to be modified, fill the ID column with the original field value, and delete the original field, rename the field
alter table table add number 1 bigint identity (1, 1) not null
go
set identity_insert table on
go
Update table set no. 1 = No
go
set identity_insert table off
go
alter table table drop column No.
go
exec sp_rename 'table. 1 ', 'number'
go
============================= ================================< br> alter table [Image] alter column [ID] int identity) not null

========================================================== ============
Alter table table add number 1 bigint identity (1, 1) not null
Go
Alter table table drop column no.
Go
Exec sp_rename 'table. No. 1', 'No'
Go

========================================================== ============

 

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.