Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Rollback causes Identity to Increment when inserti

Author  Topic 

azamsharp
Posting Yak Master

201 Posts

Posted - 2006-11-15 : 21:49:04
Hi,

When I Rollback the transaction which consists of the insert statements then the identity is incremented. Is there any way that id does not increment when I rollback the transaction.



Mohammad Azam
www.azamsharp.net

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-11-15 : 21:54:24
No, that's how identity works, if you have to have contiguous numbers you have to create that yourself.

You can run DBCC CHECKIDENT to check the identity value and even reset it, but you wouldn't want to do that every time you rollback a transaction.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-11-15 : 21:56:44
Identity increment in no way related to completion of a transaction. Whether transaction succeeds or fails, identity is always incremented. So there is no way you can stop it from being incremented when transaction gets rollbacked.

But, why in the first place, you want to do it?

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

azamsharp
Posting Yak Master

201 Posts

Posted - 2006-11-15 : 22:24:44
Hi,

Thanks for the reply. I really appreciate it!

Mohammad Azam
www.azamsharp.net
Go to Top of Page
   

- Advertisement -