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

  • SEARCH
  • Home
  • 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 6745923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:15:43+00:00 2026-05-26T12:15:43+00:00

I have inherited code that looks like this: Stored Procedure UpdateSomeStuff Update Table1 Set

  • 0

I have inherited code that looks like this:

Stored Procedure UpdateSomeStuff

Update Table1 Set Col1=Para@1

IF @@Error > 0 Goto ERR

Update Table2 Set Col1=Para@2

IF @@Error > 0 Goto ERR

RETURN 0

ERR:

return  -1;

This sp is called by ADO.NET in c# like this

try
{
    myCommand.ExecuteNonQuery();
}
catch (System.Exception ex)
{
    _log.Error(ex);
    throw();
}
finally
{
    if(myConnection!=null)
    {
            myConnection.Close();
    }
}

I am just asking myself: Is the part IF @@Error > 0 Goto ERR good for anything? If an error happens the sp would return anyway and an exception would be caught in the calling method.

The calling code does not handle the return value 0 and -1. My plan would be to remove all Errorhandling in the Stored Procedure an have the same result. Am I right or is there something I missed?

  • 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-26T12:15:44+00:00Added an answer on May 26, 2026 at 12:15 pm

    My ‘2 cents’ you will kill the performance by removing if@error statements.
    so either you implement try catch as mitch says or do not remove them.
    Just think if there is error at first statement then it will not attempt to execute 2nd statement and so on when you have if@error statements.

    and if you remove them , sql server is going to try next statement until it reaches the limit when it decides it can not go ahead with further processing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that looks like this: public class A { public void doStuff()
I have ' inherited ' a brilliant piece of TSQL code that does this:
I have a DOM situation that looks like this: A is an ancestor of
I currently have some code that looks like: -(UIView)someMethod { CGRectMake(0,0,100,100); UILabel *label =
I have the following code in specman that I inherited: some_method() is { var
I have inherited a 1000-line stored procedure which produces XML by using FOR XML
I have just inherited some code and part of that code is to show
I have inherited a code-base that uses ASP.NET MVC 3. I'm learning it as
I have a simple class called Tuple. which looks like this : class tuple
In WPF, I have a custom control that inherits from TreeView. The code is

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.