SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to add error handling for stored procedures?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pras2007
Posting Yak Master

216 Posts

Posted - 02/14/2013 :  09:32:36  Show Profile  Reply with Quote
Hello All,

I have been given several stored procedures in SQL Server 2005; the goal is to modify the SP to raise an error for any error(s) that may occur. Does anyone know how to accomplish this task?

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 02/14/2013 :  09:37:58  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
see this
http://www.nigelrivett.net/Products/DWBuilder/TraceTable.html

Just add a try - catch block to trap erors.
This then logs the error and re-raises it.
This will again be trapped and logged by a calling sp.
The good thing is that as long as the handling is in a higher level sp then all calling sps will have their errors trapped - I prefer to add it to all sps though so you get the stack.


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000