INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

IDENTITY_INSERT status

IDENTITY_INSERT status

(OP)
I need to insert values into an identity field, but I don't know what the normal status of IDENTITY_INSERT is for this database. Is there any way to determine the status of IDENTITY_INSERT prior to running the INSERT statement?

RE: IDENTITY_INSERT status

I don't think there is. When you set identity_insert on, it is only on "for the session". This means that if you disconnect your session and then re-connect, identity_insert will not be on for any of your tables.

Since you are having this problem, I can only assume it's because you attempted to set it on and it failed. Whenever I need to use identity_insert, I always approach it the same way that I use transactions. Every transaction has a definite starting point (begin transaction) and a definite ending point (commit or rollback transaction).

Basically, whenever you set identity_insert on, you should always set it off. This will save you this kind of trouble.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom

RE: IDENTITY_INSERT status

(OP)
thank you

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close