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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:04:46+00:00 2026-05-11T05:04:46+00:00

I have a MSSSQL stored procedure performing a distributed transaction that looks like this:

  • 0

I have a MSSSQL stored procedure performing a distributed transaction that looks like this:

SET XACT_ABORT ON; SET NOCOUNT ON;  BEGIN TRY   BEGIN DISTRIBUTED TRANSACTION     insert into LNKSRV.INST.dbo.zz (id, val) values (1, 'a');   insert into LNKSRV.INST.dbo.zz (id, val) values (2, 'b');     COMMIT TRANSACTION END TRY BEGIN CATCH   if (XACT_STATE() <> 0)    BEGIN     ROLLBACK TRANSACTION;   END   print ERROR_MESSAGE();   print ERROR_LINE();   print ERROR_SEVERITY();  END CATCH 

This works fine.

If I add this 3rd insert statement:

  insert into LNKSRV.INST.dbo.zz (id, val) values ('error', 'b'); 

…it fails correctly — the transaction is rolled back on the remote server and control passes to the CATCH block and I get information about the error (can’t convert ‘error’ to int).

But if I add this insert statement:

  insert into LNKSRV.INST.dbo.zz (id, val) values (-1, 'b'); 

..and I have a check contraint on the remote table requiring values > 0 in the id column, then things do not work as I expect. The transaction DOES roll back, but control DOES NOT transfer to the catch block. Instead, execution just dies and this is printed to the output window:

The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction 

Why? I need to log these errors in the catch blog.

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T05:04:46+00:00Added an answer on May 11, 2026 at 5:04 am

    Since the distributed transaction coordinator is handling this, when the transaction fails on the distributed part of the transaction, the DTC sends a message in the form of an attention, which stops your code from executing, and which the TRY/CATCH cannot process.

    SQL Server can detect on your end when you are trying to insert an incorrect data type into a table (even on a remote instance) but the constraint is processed on the linked server, which causes the attention to be sent to DTC and your TRY/CATCH to be ignored.

    For more information see the first ‘Note’ section in the ‘Using TRY…CATCH in Transact-SQL’ section of SQL Server 2008 Books Online, located at:

    http://msdn.microsoft.com/en-us/library/ms179296.aspx

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

Sidebar

Related Questions

I have a table in a MSSQL database that looks like this: Timestamp (datetime)
I have a mssql stored procedure question for you experts: I have two tables
I have a MSSQL Database, and I have a stored procedure for any possible
I have a stored procedure in MSSQL 2005 Server SQLCLR. Is it possible to
I'm converting an MSSQL DB to MySQL DB and I have a stored procedure
Is there any way that I can make sure that a stored procedure completely
I have this idea that using SQL VIEWS to abstract simple database computations (such
Say I have an MSSQL table with two columns: an int ID column that's
If I have an mssql varchar[1024] that is always empty in a table, how
I have a web application that I'm writing (C#, MSSQL) and I need 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.