SQL Server中有DBCC CHECKIDENT的替代方法(例如Alter Column Query)吗?
答案 0 :(得分:2)
您可以尝试这样做。
SET IDENTITY_INSERT [MyTable] ON
INSERT INTO Mytable(ID,name)values (@AutoIncrementvalue-1,'siva')
SET IDENTITY_INSERT [MyTable] OFF
--Insert into table or whatever here
-- finally delete the value which we inserted initially
DELETE FROm MyTable WHERE ID=@AutoIncrementvalue-1
但我总是喜欢DBCC CHECKIDENT
。
您可以使用它来满足您的TL。