ironcurtain
ironcurtain

Reputation: 690

Query multiple SQL Server tables in parallel

I would like to know if there is way that I can run multiple SELECT queries or stored procedures in parallel? For a long time I was using one stored procedure which looks like below:

SELECT 1.......

SELECT 2 .......

SELECT 3 .......

Then I got DataSet with multiple DataTables.

Now I would like to run each SELECT statements parallel. I am not sure if I can do this using the same SqlConnection or if I have to use a separate connection for each query?

Do I have to use threads?

Upvotes: 1

Views: 1071

Answers (1)

Manoj Pandey
Manoj Pandey

Reputation: 1397

SQL Server will run all the 3 SELECTs in same session and in sequence as per you've done above.

If you want to execute all 3 SELECTs in parallel then you will have to invoke 3 threads (3 SPIDs, by creating separate connections) and execute by any script, like C# or VBA. But still its not guaranteed if they will run exactly parallel.

Upvotes: 1

Related Questions