Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 INSERT INTO - Identity_insert failure

Author  Topic 

The Chef
Starting Member

1 Post

Posted - 2012-05-10 : 19:34:25
Hi,
I'm trying to manually insert a few rows into a table (using SQL Server 2005).
The error im recieving is:
Cannot insert explicit value for identity column in table 'User' when IDENTITY_INSERT is set to OFF

I'm ok with the actual error - but not sure how to get round it...
I've tried :
Set IDENTITY_INSERT User ON

but this errors with:
Table 'User' does not have the identity property. Cannot perform SET operation.

Any other ideas for switching Identity Insert On/Off?

Thanks

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-10 : 19:40:36
User is a reserved keyword - not a good name to use for a user table if you can help it. I know this does not correlate with the error message, but can you see if this works?
Set IDENTITY_INSERT [User] ON
If that does not seem to work, script the table from object explorer and really verify that there is no identity column or try
SELECT * FROM sys.columns WHERE OBJECT_NAME(OBJECT_ID) = 'User' AND is_identity = 1;
If there is no identity column, can you post your insert query that is generating the error message?
Go to Top of Page
   

- Advertisement -