Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 24th, 2006, 08:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default IDENTITY_INSERT

Hi,

Does anyone know where the status of IDENTIY_INSERT is stored in MS SQL server? I mean where I can get the status of this being ON or OFF and for which table is that last set. I ams ure it is somewhere in the system tables. But didn't get a clue. If someone know please post it here.

Thanks,

_________________________
- Vijay G
Strive for Perfection
__________________
- Vijay G
 
Old November 24th, 2006, 10:32 AM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Wellington, FL , USA.
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I have the system table schema poster at my office. I can take a look at it and let you know. I'm sure it is on there...

Scott Klein
Author - Professional SQL Server 2005 XML
http://www.wrox.com/WileyCDA/WroxTit...764597922.html
 
Old November 24th, 2006, 10:51 AM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

It's actually buried in a status column... this will dig it out...

Code:
 SELECT so.Name AS TabName,
        sc.Name AS IdentityColName 
   FROM SYSCOLUMNS sc,
        SYSOBJECTS so
  WHERE sc.ID = so.ID
    AND sc.ColStat & 1 = 1


--Jeff Moden
 
Old November 27th, 2006, 10:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Jeff,

I think you got it the other way. One can always list the identity columns using system tables. But my question is using system tables how do I find which table has currently set the IDENTITY_INSERT value ON/OFF.

Or Let me rephrase it.

How do I find if the IDENTITY_INSERT is ON or OFF using system tables?

Eg: say I set IDENTITY_INSERT ON for some table and I am not setting it OFF, If the same is set ON again for someother table or for the same table, sql server errs saying it was set ON for so and so table and I am trying to set it ON/OFF for so and so table.

I am looking to break that. Before it errs me out on that, Let me check the status of IDENTITY_INSERT, if ON or OFF, and if ON for which table. i suspect this being set somewhere in some system table and I am kind of running out thoughts, so I posted here. Let me see if I can find it out today myself.

Thanks for your effort.
cheers.

_________________________
- Vijay G
Strive for Perfection
 
Old November 27th, 2006, 02:10 PM
Friend of Wrox
Points: 1,536, Level: 15
Points: 1,536, Level: 15 Points: 1,536, Level: 15 Points: 1,536, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2006
Location: , MI, USA.
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

You're right... The code I posted only show what the IDENTITY columns are and not whether IDENTITY_INSERT is on or off.

Two things... first, I don't think it matters because it is session sensitive.
Second, sorry, I have no idea... it's not in any of the main system tables that I looked at.

--Jeff Moden




Similar Threads
Thread Thread Starter Forum Replies Last Post
Identity_insert problem Shuchik Classic ASP Basics 1 August 30th, 2007 05:51 AM
Linked server with Identity_insert on b_amit76 SQL Server 2000 2 February 22nd, 2005 12:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.