我不小心删除了数据库中的一行,我想重新插入该行。问题在于表的主键设置为自动递增,并且 IDENTITY INSERT
设置为 OFF
。我想暂时启用标识插入,以便可以插入已删除的行,然后禁用标识插入。
在 SQL Server Management Studio 中我尝试了以下操作:
SET IDENTITY_INSERT myTable ON
INSERT INTO myTable (id, name, value)
VALUES (241, 'hello', 'hello2')
SET IDENTITY_INSERT myTable OFF
第一行失败:
Msg 8105, Level 16, State 1, Line 2
'myTable' is not a user table. Cannot perform SET operation.
知道为什么吗?
最佳答案
错误描述: http://www.sql-server-performance.com/2007/not-a-user-table-cannot-perform-set-operation/
myTable 似乎并不是真正的表格。
试试这个:
SELECT * FROM sysobjects WHERE name = ‘myTable’
xtype 是什么?
关于sql - IDENTITY_INSERT ON 失败并出现错误 "...is not a user table. Cannot perform SET operation",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8688934/