开发者

Launch multiple stored procedures to run 'in the background' on SQL Server Express Edition

开发者 https://www.devze.com 2022-12-10 20:23 出处:网络
Is it possible to run multiple stored procedures that run \'in the background\'? The stored procedures must be launched from a single, master stored procedure, in the same way that multiple worker th

Is it possible to run multiple stored procedures that run 'in the background'?

The stored procedures must be launched from a single, master stored procedure, in the same way that multiple worker threads are spawned. For example:

CREATE PROCEDURE MyLauncher
AS
BEGIN
    BEGIN
      @EXEC MyBackgroundSP01 -- Runs in parallel to the other 2
      @EXEC MyBackgroun开发者_如何转开发dSP02 -- Runs in parallel to the other 2
      @EXEC MyBackgroundSP03 -- Runs in parallel to the other 2
    END
END


It is possible in SQL 2005 and later. Have look at http://rusanu.com/2009/08/05/asynchronous-procedure-execution/


No this isn't possible as you have described it. You could run multiple SQL Jobs which will execute the procedures concurrently/


According to this question you could try using the Service Broker

Asynchronous Stored Procedure Calls


If you run they in the same procedure, it will launch in the same thread (and in the same internal transaction, what can make the log very big).


Not with pure T-SQL. But you could write a little dotNET app to run them asynchronously easily enough, as long as you leave the connection option until all three are finished.


IF both Stored procedure have same parameter then you can create a new store procedure like

create third procedure
(@colname int)
as
 begin

exec first procedure
exec second procedure
end

exec third procedure

You can try it. I am sure how appropriate it is.

0

精彩评论

暂无评论...
验证码 换一张
取 消