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 2008 Forums
 Transact-SQL (2008)
 Error handling in called stored procedures

Author  Topic 

BalakrishnanShanmugham
Starting Member

6 Posts

Posted - 2015-04-14 : 05:48:01
Hi,

I have one main stored procedure. It calls other 10 stored procedures by giving input parameters.
Do I want to implement Begin Try/Begin catch in each sub procedures or in main proceudre only.

Please suggest how to achieve?
Appreciate your help.

Regards,
Bala

Kristen
Test

22859 Posts

Posted - 2015-04-14 : 06:16:12
I do both. The Inner SProc may be executed without the outer SProc, so having its own transaction /. error handling ensures that it never runs with NO transaction / error handling :)

The outer / parent SProc also having a transaction means that if some of the child SProcs run OK and then one fails then the WHOLE transaction is rolled back.

Child SProcs can cascade their errors back up to the parent.
Go to Top of Page
   

- Advertisement -