Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help - IDENTITY_INSERT weirdness

Status
Not open for further replies.

katgirl

Programmer
Jul 6, 2006
114
US
Hi,

Here's the issue. I need to insert some data into a table with an identity column.

I run the query with
SET IDENTITY_INSERT THISTable ON
Insert into THISTable

However, when I attempt to run the query, it says:
IDENTITY_INSERT is already ON for table 'SomeOtherTable'

SomeOtherTable has nothing to do with THISTable. They are not even related by a foreign key.

However, I did another insert on SomeOtherTable earlier today, which also has an identity column. And yes, I SET IDENTITY_INSERT SomeOtherTable ON... that worked fine.

What am I missing here??

Thanks
 
You should turn off identity insert when you are done with it.

Code:
SET IDENTITY_INSERT THISTable ON
Insert into THISTable....
SET IDENTITY_INSERT THISTable OFF

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
figured it out - eeeek - bad move to leave ON
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top