Rollback SQL Server 2012 Sequence

Posted by VAAA on Stack Overflow See other posts from Stack Overflow or by VAAA
Published on 2012-08-25T00:42:00Z Indexed on 2012/09/08 9:38 UTC
Read the original article Hit count: 254

I have a SQL Server 2012 Sequence object:

/****** Create Sequence Object ******/
CREATE SEQUENCE TestSeq
START WITH 1
INCREMENT BY 1;

I have a SP that runs some queries inside a transaction:

BEGIN TRAN

SELECT NEXT VALUE FOR dbo.TestSeq

<here all the query update code......>

ROLLBACK TRAN

If the transaction fails all the updates are rolledback without problem but the Sequence is not rolled back I guess because Its out of the scope of the transaction.

Any clue on way to handle that?

Thanks

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about sql-server-2012