Execute concurrently SQL Server
I am doing some exec
in a store procedure, Is there a way to execute simultaneously those exec, they are independent so there are no race conditions...
Also, I am doing things (开发者_如何学Creally more complex) like:
SET @template = 'SELECT FROM ... INSERT ...'
SET @template2 = 'SELECT FROM ... INSERT ...'
EXEC(@template);
EXEC(@template2);
The way to do this is to have your code call each of the EXEC commands asynchronously. SQL Server has no way to explicitly execute stored procedures asynchronously.
Note also that executing them asynchronously may or may not improve performance.
The easiest way would be to open two query windows from SQL Server Management Studio and execute both sets of commands in the two windows.
Query Window 1
SET @template = 'SELECT FROM ... INSERT ...'
EXEC(@template);
Query Window 2
SET @template2 = 'SELECT FROM ... INSERT ...'
EXEC(@template2);
精彩评论