Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDENTITY_INSERT ON fails with error "...is not a user table. Cannot perform SET operation"

Tags:

sql

sql-server

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?

like image 610
bradforj287 Avatar asked Dec 31 '11 15:12

bradforj287


1 Answers

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?

like image 128
Keith Walton Avatar answered Oct 11 '22 22:10

Keith Walton