What is MARS commection

Igor Korot 46 Reputation points
2025-01-26T22:47:42.9533333+00:00

Hi, ALL,

I thought that MARS connection is for the following scenario:

SELECT field1 FROM table1 WHERE

SELECT field2 FROM table2 WHERE table2.field1 = table1.field1_value

As you can see there are 2 open statements for which MARS is a solution,

Apparently its not because issuing BEGIN TRANSACTION fails with "A transaction that was started in a MARS batch is still active..."

Cam anybody explain what is happening?

Thank you,

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,377 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 116K Reputation points MVP
    2025-01-26T23:04:57.97+00:00

    MARS is mainly intended for the case you read a result set row-by-row, and you want to update rows as you read them.

    While there is nothing to prevent you from submitting for instance to SELECT statements in the same connections with the MARS, it is necessarily not particularly useful. And specifically, there is no parallel execution, as all execution under MARS is interleaved.

    I have never found MARS to be a feature of much use, and the best remedy for your problems is stop using MARS. As you have experienced there can be some confusing behaviour.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.