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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:29:54+00:00 2026-06-10T14:29:54+00:00

I have a simple TRY CATCH with an embedded TRANSACTION in the below query.

  • 0

I have a simple TRY CATCH with an embedded TRANSACTION in the below query.
I have a column name mistyped in the query: ItemID1 in the second UPDATE inside the TRANSACTION
When I run the query, I get the below error message which has a severity higher than 10:

Msg 207, Level 16, State 1, Line xxx Invalid column name ‘ItemID1’.

The 1st UPDATE ran successfully (where I was hoping it would ROLLBACK).
This shows that it never went to the CATCH block.
As per my understanding, the CATCH catches errors above severity 10. This one is severity 16, hence it should have caught it.
Any ideas why CATCH was never executed?

BEGIN TRY
    IF OBJECT_ID('tempdb..#MyTempTable') IS NOT NULL 
        DROP TABLE #MyTempTable
    CREATE TABLE #MyTempTable
        (
          ObjectID UNIQUEIDENTIFIER , OrgID NVARCHAR(20)
        )

    INSERT  INTO #MyTempTable
            SELECT  ObjectTable1.ObjectID AS ObjectID ,OrgID 
            FROM    ObjectTable1 WITH ( NOLOCK ) INNER JOIN Org WITH ( NOLOCK ) ON ObjectTable1.OrgID = Org.OrgID
            WHERE   OrgID IN ('Blah1', 'Blah2')

    INSERT  INTO #MyTempTable
            SELECT  ObjectTable2.ObjectID AS ObjectID, OrgID
            FROM    ObjectTable2 WITH ( NOLOCK ) INNER JOIN Org WITH ( NOLOCK ) ON ObjectTable2.OrgID = Org.OrgID
            WHERE   OrgID IN ('Blah3', 'Blah4')

    SELECT  * FROM #MyTempTable

    BEGIN TRANSACTION
        UPDATE  ObjectTable1 
        SET ItemID = NULL FROM ObjectTable1 INNER JOIN #MyTempTable ON #MyTempTable.ObjectID = ObjectTable1.ObjectID
        PRINT 'Updated ' + CAST(@@ROWCOUNT AS VARCHAR(20)) + ' Objects in ObjectTable1'

        UPDATE  ObjectTable2
        SET     ItemID = (ItemID1 + 1) FROM ObjectTable2 INNER JOIN #MyTempTable ON #MyTempTable.ObjectID = ObjectTable2.ObjectID
        PRINT 'Updated ' + CAST(@@ROWCOUNT AS VARCHAR(20)) + ' Objects in ObjectTable2'
    COMMIT
    DROP TABLE #MyTempTable
END TRY

BEGIN CATCH
    IF @@TRANCOUNT > 0 
        ROLLBACK
    DROP TABLE #MyTempTable

    DECLARE @ErrMsg NVARCHAR(4000) ,
        @ErrSeverity INT
    SELECT  @ErrMsg = ERROR_MESSAGE() ,
            @ErrSeverity = ERROR_SEVERITY()
    RAISERROR(@ErrMsg, @ErrSeverity, 1)
END CATCH
  • 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-06-10T14:29:55+00:00Added an answer on June 10, 2026 at 2:29 pm

    Object name resolution errors aren’t caught by TRY-CATCH.
    From MSDN article here:

    The following types of errors are not handled by a CATCH block when they occur at the same level of execution as the TRY…CATCH construct:

    • Compile errors, such as syntax errors, that prevent a batch from running.
    • Errors that occur during statement-level recompilation, such as object name resolution errors that occur after compilation because of deferred name resolution.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to this about Try/Catch. In the code below I have a simple
I have a simple try/catch block try { // Open the connection _connection.Open(); //
I have this simple try catch for throwing cin exceptions, but it never throws
I have done this simple catch: try { echo Request::factory() ->execute() ->send_headers() ->body(); }catch(Exception
I have Simple java program named MainController.java. Wehn I try to compile it from
I'd like to try out the D programming language. I have simple pet project
I have a simple problem but no matter what I try I can't see
i have downloaded Swift Mailer from their website and try to send simple email
I will try to keep this as simple as possible. I have a rather
I have some problem's with a simple application in JSF 2.0. I try to

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.