如何在客户端关闭程序,或计算机的情况下,执行的存储过程还能照样执行下去?(30分)

  • 主题发起人 WilliamGui
  • 开始时间
W

WilliamGui

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟想实现以上的功能,
做了个试验,
写了一个存储过程,执时时间很长,真正执行的时间可能需要一两个小时以上,
在试验存储过程中我用了waitfor延时,
用delphi写一执行程序,异步执行,设置
ExecuteOptions:=[eoAsyncExecute]
且存储中给一全局临时表增加记录,如下
if exists (select * from sysobjects
where id = object_id('p1'))
drop procedure p1
GO
create procedure p1
as begin
declare @i int
select * into ##temptable1 from t1 where 1=0
select @i=0
while @i<100
begin
insert into ##temptable1 values(@i)
WAITFOR DELAY '00:00:02'
select @i=@i+1
end
drop table ##temptable1
end
执行程序,可以查到临时表的数据,
但退出程序,有警告信息,存储过程被中断,不再执行,
但我直接断开网线,存储过程还是执行的,
也就是如何在程序退出时,不发送中断执行的信息给数据库服务器!????
请教



 
将该存储过程的执行利用sql server提供的“作业计划”来管理。
 
在客户端用线程方式调用.但客户端一定不能关闭.
因为如果客户端关闭的话,服务端对应的服务对象将释放,不可能还执行的.
 
顶部