T-SQL 中的异步存储过程调用 [英] Async Stored Procedure Call in T-SQL

查看:41
本文介绍了T-SQL 中的异步存储过程调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从另一个存储过程异步调用另一个存储过程?

How one can make an async call to a stored procedure from another one?

假设我有两个存储过程,SP1 和 SP2(这是一个长时间运行的存储过程,需要很多时间来执行,并且不返回任何结果).

Assume I have two stored procedures, SP1 and SP2 (this is a long running stored procedure, takes much time to execute, and doesn't return any result).

存储过程 SP1 定义如下:

The stored procedure SP1 is defined like this:

CREATE PROCEDURE SP1
AS
BEGIN

  --custom business logic

  --CALL to SP2, but async

  EXEC SP2

END

在 SQL Server 2008/2012 中如何像上面那样对 SP 进行非阻塞/异步调用?

How could you make a non-blocking/async call to SP like the above in SQL Server 2008/2012?

推荐答案

有一次我试图通过将存储过程包装到 Job 中,然后通过 sp_start_job system sp 调用过程中的作业来实现这一点.

There was once I tried to achieve this by wrapping the stored procedure into Job, and then Calling the job in the procedure through sp_start_job system sp.

EXEC dbo.sp_start_job N'Job name' ;

这篇关于T-SQL 中的异步存储过程调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆