I've accidentally deleted a row in a database and I would like to reinsert the row. The problem is that the primary key is set to auto increment and IDENTITY INSERT
is set to OFF
for the table. I would like to temporarily enable identity insert so I can insert the deleted row, then disable identity insert.
In SQL Server Management Studio I attempted the following:
SET IDENTITY_INSERT myTable ON
INSERT INTO myTable (id, name, value)
VALUES (241, 'hello', 'hello2')
SET IDENTITY_INSERT myTable OFF
The first line fails out with this:
Msg 8105, Level 16, State 1, Line 2
'myTable' is not a user table. Cannot perform SET operation.
Any idea why?
Error description: http://www.sql-server-performance.com/2007/not-a-user-table-cannot-perform-set-operation/
myTable doesn't appear to really be a table.
Try this:
SELECT * FROM sysobjects WHERE name = ‘myTable’
What is the xtype?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With