Friday, March 9, 2012

identity field and IDENTITY_INSERT is Off

ok, so i get this error,
Exception Details: System.Data.SqlClient.SqlException: Cannot insert explicit value for identity column in table 'TBL_LAPTOP_BOOKINGS' when IDENTITY_INSERT is set to OFF.

i ran SET INDENTITY_INSERT TBL_LAPTOP_BOOKINGS ON before i ran my script... and i also checked, we are running SQL 2000 with service pack four, because of the cursor error...

so im just wondering, is there anyway to make identity_insert to always be on, or any other way to have a unique id in my booking_id field??

Thanks Guys, JustinJust to clarify: did you SET IDENTITY_INSERT YourTable ON in the same connection as the one where you attempted the insert?

I'm not certain that you always want IDENTITY_INSERT set to ON.

Regards,

hmscott

No comments:

Post a Comment