启动多个存储过程以“在后台”运行在 SQL Server Express 版本上
是否可以运行多个“在后台”运行的存储过程?
存储过程必须从单个主存储过程启动,就像生成多个工作线程一样。例如:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
在 SQL 2005 及更高版本中这是可能的。看看 http://rusanu.com/2009/08/05/异步过程执行/
It is possible in SQL 2005 and later. Have look at http://rusanu.com/2009/08/05/asynchronous-procedure-execution/
不,正如您所描述的那样,这是不可能的。您可以运行多个 SQL 作业,这些作业将同时执行过程/
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).
纯 T-SQL 则不然。但是您可以编写一个小 dotNET 应用程序来足够轻松地异步运行它们,只要保留连接选项直到所有三个都完成即可。
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
You can try it. I am sure how appropriate it is.