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)
 Exceptions in SQL Server

Author  Topic 

lopes_andre
Starting Member

12 Posts

Posted - 2009-12-02 : 13:58:04
Hi,

I have a procedure that calls other procedures and some procedures produce errors.

I need to catch an error with an exception and continue the procedure without aborting.

How to do this in SQL Server.


PS: Sorry for my bad english.

Best Regards,
André.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-12-02 : 14:03:02
There is a try-catch construct, as well as RAISERROR that might be helpful

BEGIN TRY
{ sql_statement | statement_block }
END TRY
BEGIN CATCH
{ sql_statement | statement_block }
END CATCH
[ ; ]


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

lopes_andre
Starting Member

12 Posts

Posted - 2009-12-02 : 14:35:44
Thanks for the reply. I found that the error only appear when the procedure is called from an external application... I will try to solve the problem on the side of application call.

Best Regards.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-03 : 03:42:49
Have you read this?
http://www.sommarskog.se/error-handling-I.html#Yukon

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -