简体   繁体   English

启动多个存储过程以在SQL Server Express Edition上“在后台”运行

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

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 MyBackgroundSP02 -- 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. 在SQL 2005及更高版本中是可能的。 Have look at http://rusanu.com/2009/08/05/asynchronous-procedure-execution/ 看一下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/ 您可以运行多个SQL作业,这些作业将同时执行过程/

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. 我确定这是多么合适。

According to this question you could try using the Service Broker 根据这个问题,您可以尝试使用Service Broker

Asynchronous Stored Procedure Calls 异步存储过程调用

如果以相同的过程运行它们,它将在相同的线程中启动(并在相同的内部事务中运行,这会使日志很大)。

Not with pure T-SQL. 不能使用纯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. 但是,您可以编写一个小小的dotNET应用程序,以足够轻松地异步运行它们,只要您保留连接选项,直到全部三个完成即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM