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 6847793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:47:19+00:00 2026-05-27T00:47:19+00:00

I have a large generated script. It has multiple batches ( GO statements). The

  • 0

I have a large generated script. It has multiple batches (GO statements). The first line is BEGIN TRAN

If any errors occur during execution, either raised myself using RAISERROR, or raised by SQL Server, I want to rollback the transaction. I want the script to continue executing until the very end, then rollback, not abort execution as soon as any error occurs.

Checking @@error <> 0 at the end of the script doesn’t seem to be sufficient, because if the last statement in the script succeeds, @@error will be 0, even though previous statements failed.

I can’t declare a @rollback BIT at the very beginning because the script is segmented into multiple batches, and so the variable is out of scope.

I understand that RAISERROR doesn’t mean my transaction will be rolled back.

Any suggestions on the best way to implement this in a SQL 2000 compatible manner?

  • 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-27T00:47:20+00:00Added an answer on May 27, 2026 at 12:47 am

    You can always use SET CONTEXT_INFO to pass ‘out-of-band’ information, and read it later using CONTEXT_INFO(). If an error occurs, set the context info to a value which you check just before commit.

    This answers your question of how to do it, but I really have to express my doubts about why do it in the first place. For one many errors will abort the transaction anyway so you may blindly proceed believing that is safe to continue and rollback only to discover that there is nothing to rollback and all your erroneous script after the exception has committed. Second, for the exceptions than do not abort the transaction, is still very questionable to do any work only to roll it back. Your request is so out of the beaten path than I must wonder if you really understand all the implications of what you’re doing.

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

Sidebar

Related Questions

I have large batches of XHTML files that are manually updated. During the review
I'm have build an up php script to host large number of images upload
Ok, I have a simple PHP script, that generates a thumbnail for a large
I have a large PHP generated table of users from a database. Each username
I have an automated test running on my program that generates some large MPG
I have large data sets (10 Hz data, so 864k points per 24 Hours)
I have large images displayed in a grouped tableview. I would like the images
I have large database table, approximately 5GB, now I wan to getCurrentSnapshot of Database
In my application I have large area (≈5000x5000pts) and I must allow user to
I'm developing a website in PHP and I have large JS files that I

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.