|
-
Sep 16th, 2008, 01:23 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] identity seed incremented in transaction
HI,
I have the attached
On inspecting my T_SQL I think I need to insert Rollback in the INSERT part of the SPROC. For example when USERID (field) was missing in tb_Translog, the identity for that table was still executed because the next correction entry had skipped a record.
I wonder if someone can give some advice pls.
PS I have included a ROLLBACK for every error message but I am still getting the indentity seed incremented. I am updating the file. Anyone can give me some expert help on these transactios pls
Last edited by angelica; Sep 16th, 2008 at 04:25 PM.
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it! 
-
Sep 16th, 2008, 02:22 PM
#2
Re: identity seed incremented in transaction
A Rollback does not affect Identity values. Once an Identity value has been used it is gone for good.
-
Sep 16th, 2008, 02:32 PM
#3
Thread Starter
Frenzied Member
Re: identity seed incremented in transaction
Dont quite understand it.
If I have an error or condition is not satisified I put a ROLLBACK. The contents of the record do NOT got through but the identity seed is incremented ! Is this normal even though I put it inside a transaction?!
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it! 
-
Sep 16th, 2008, 02:59 PM
#4
Re: identity seed incremented in transaction
The Identity value is not affected by the Rollback command. The value can only be generated one time and one time only. By the time the Rollback is sent the action has already completed. You can do other things such as getting the current identity of the table in question at the start of each insert and then if a rollback occures re-seed the table to that value.
PS by the way I think this is way to much trouble to even consider.
Last edited by GaryMazzone; Sep 16th, 2008 at 03:11 PM.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Sep 16th, 2008, 04:24 PM
#5
Thread Starter
Frenzied Member
Re: identity seed incremented in transaction
ok Gary,
Thanks to you both, at least I set my mind at rest Im doing it the right way.
I wont go into that trouble as you said. cheers
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it! 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|