Sql
1、SET IDENTITY_INSERT TableName ON只适用于INSERT操作标识符,对标识符的UPDATE无效。若要更新标识符,只有以表复制的方式创建新的表,再删除原表。
CREAT TABLE T_temp(...)
Go
SET IDENTITY_INSERT T_temp ON
INSERT T_temp(Columns...) SELECT * FROM T
SET IDENTITY_INSERT T_temp OFF
DROP TABLE T
Go
EXEC sp_rename N'T_temp',N'T'
2、修改列:Go
SET IDENTITY_INSERT T_temp ON
INSERT T_temp(Columns...) SELECT * FROM T
SET IDENTITY_INSERT T_temp OFF
DROP TABLE T
Go
EXEC sp_rename N'T_temp',N'T'
Alter Table T Alter Column Name nchar(20)
ALTER TABLE T ADD ID_temp int
ALTER TABLE T ADD ID_temp int