简体   繁体   English

如何更改数据类型SQL Server 2008 R2

[英]how to change data type sql server 2008 R2

I am trying to change a column from identity(1,1) NOT null to INT NOT NULL? 我试图将一列从identity(1,1)NOT null更改为INT NOT NULL?

What is the SQL command to alter this table? 更改此表的SQL命令是什么?

i already try but not success , the data still auto increment. 我已经尝试但没有成功,数据仍然会自动递增。

After altering your column datatype you need to set Identity insert to on for you table, like below. 更改列数据类型后,需要将表的“身份插入”设置为“开”,如下所示。

SET IDENTITY_INSERT YourTableName ON

After this you should be able to insert your values on the column that was an Identity column. 之后,您应该能够在作为Identity列的列上插入值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM