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 2005 Forums
 Transact-SQL (2005)
 RETURN from inside a TRANSACTION inside a TRY

Author  Topic 

tijujohn83
Starting Member

4 Posts

Posted - 2009-08-25 : 08:54:27
I got strange runtime error while i tried to return from an if statement, which was inside a transaction, which was inside a TRY block.
Does anybody know anything about it.



BEGIN TRY
BEGIN TRANSACTION

IF (something)
RETURN

/* some code */


COMMIT TRAN
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRAN
END CATCH


Some best things in life can't be bought by money.

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-08-25 : 09:33:05
Yeah, you need to Rollback the transaction before returning.
Go to Top of Page
   

- Advertisement -