Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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
Reply With Quote
  #4 (permalink)  
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
Reply With Quote
  #5 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:47 PM.


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