Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6212901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:35:55+00:00 2026-05-24T06:35:55+00:00

I am running a stored procedure in SQL Server 2008 inside a try/catch. The

  • 0

I am running a stored procedure in SQL Server 2008 inside a try/catch. The stored procedure and the stored procs it calls raise a few errors but in the try/catch you only get the last error from the stored procedure that you are running.

Is there a way/trick to be able to somehow catch ALL the errors generated by child stored proc calls while running a particular stored procedure? (assume that you have no access to any stored procedures so you can’t modify where they can write the error, i.e. you can’t just change all the stored procedures to stop raising errors and instead write them to some table and in your catch read from that table)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:35:56+00:00Added an answer on May 24, 2026 at 6:35 am

    Here is a good resource for how to deal with error handling in SQL Server.
    http://www.sqlservercentral.com/articles/Development/anerrorhandlingtemplatefor2005/2295/

    However, some of the methods require that you have the ability to change the code in order to capture the errors. There is really no way of getting around this. You can’t just ignore the error, keep processing, and then come around later to deal with the error. In most, if not all, languages, exceptions have to be dealt with at the time the exception was raised. T-SQL is no different.

    I personally use a stored procedure to log any error whenever it occurs. Here is what I use:

    CREATE PROCEDURE [dbo].[Error_Handler]
    @returnMessage bit = 'False'
    WITH EXEC AS CALLER
    AS
    BEGIN
    
      INSERT INTO Errors (Number,Severity,State,[Procedure],Line,[Message])
      VALUES (
        ERROR_NUMBER(),
        ERROR_SEVERITY(),
        ERROR_STATE(),
        isnull(ERROR_PROCEDURE(),'Ad-Hoc Query'),
        isnull(ERROR_LINE(),0),
        ERROR_MESSAGE())
    
      IF(@returnMessage = 'True')
      BEGIN
        select Number,Severity,State,[Procedure],Line,[Message]
        from Errors
        where ErrorID = scope_identity()
      END
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure running on sql server 2008 looping over a table
I have a very long-running stored procedure in SQL Server 2005 that I'm trying
How can I know which stored procedure is running in SQL Server 2005. And
I've got a T-SQL stored procedure running on a Sybase ASE database server that
Using Entity Framework 4 with stored procedures and SQL Server 2008 SP1... When running
I am running sql server 2008 express and i need to schedule some stored
I have a stored procedure in SQL Server 2008 that will insert a record
Using SQL Server 2008 I created a Stored Procedure called MyStoreProc and it runs
I am attempting to troubleshoot a slow running stored procedure in SQL Server 2005.
For a large database (thousands of stored procedures) running on a dedicated SQL Server,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.