更新时间:2023-12-01 10:23:22
Alter Table Names
Add Id_new Int Identity(10, 1)
Go
Alter Table Names Drop Column ID
Go
Exec sp_rename 'Names.Id_new', 'ID', 'Column'
请检查.
http://***.com/questions/1049210/adding-an-identity- to-an-existing-column [ ^ ]
Please check.
http://***.com/questions/1049210/adding-an-identity-to-an-existing-column[^]
您忘记了列名-它应该在单词"COLUMN"和"INT"之间
You forgot the column name - it should be between the words "COLUMN" and "INT"
删除旧列并添加新列.
Remove the old column and add new one.
--SQL Script:
ALTER TABLE Users DROP PK_Users
GO
ALTER TABLE Users DROP COLUMN UserID
GO
ALTER TABLE Users ADD UserID int NOT NULL IDENTITY(1,1)
GO
ALTER TABLE Users ADD CONSTRAINT PK_Users PRIMARY KEY CLUSTERED ([UserID] ASC)
GO