Dustin Davis
Dustin Davis

Reputation: 14585

Native TSQL support for parallel queries

Is there native support for executing queries in parallel from a stored procedure in SQL Server 2008 R2? Take this pseudo code for example

create proc dbo.MySproc
as
   delete from SomeTable where Predicate = true [as parallel]
   delete from AnotherTable where Predicate = false [as parallel]

   [wait for queries]

   select * from SomeTable join AnotherTable on Predicate = true

I've seen examples of doing this but they require installing non native CLR procedures which is what I want to avoid.

NOTE: I'm not talking about execution plans, I mean running two non related queries at the same time async, not one after the other.

Upvotes: 5

Views: 928

Answers (2)

Michał Powaga
Michał Powaga

Reputation: 23183

How can I run sql server stored procedures in parallel? - it's about stored procedures, but maybe you'll find something useful.

Upvotes: 2

Russell McClure
Russell McClure

Reputation: 4851

No, there is no T-SQL syntax for controlling parallelism.

There are a number of games you can play to get something similar but they all require a non T-SQL entity. For example, SQL Server Jobs, CLR SPs that spawn multiple threads, C# app that spawns the threads, use of sqlcmd to execute T-SQL etc.

Upvotes: 6

Related Questions