update SourceDB.dbo.gm_campaign_fb set next_time='9999-01-01' where next_time is null;
update SourceDB.dbo.gm_campaign_fb
set next_time=isnull((select MIN(login_time) from SourceDB.dbo.gm_campaign_fb where login_userid=a.login_userid and login_time>a.login_time),'9999-01-01')
from SourceDB.dbo.gm_campaign_fb a
where a.next_time='9999-01-01'上面这个语句是我的SQL作业里面的任务计划,怎么设置如果超过5分钟还没有执行成功或者失败(原因是锁表了),就断开任务?
update SourceDB.dbo.gm_campaign_fb
set next_time=isnull((select MIN(login_time) from SourceDB.dbo.gm_campaign_fb where login_userid=a.login_userid and login_time>a.login_time),'9999-01-01')
from SourceDB.dbo.gm_campaign_fb a
where a.next_time='9999-01-01'上面这个语句是我的SQL作业里面的任务计划,怎么设置如果超过5分钟还没有执行成功或者失败(原因是锁表了),就断开任务?
在 Microsoft SQL Server 返回锁定错误前经过的毫秒数。 值为 -1(默认值)时表示没有超时期限(即无限期等待)。 当锁等待超过超时值时,将返回错误。 值为 0 时表示根本不等待,一遇到锁就返回消息。 你要设置5分钟,也就是1000*60*5 = 300000,那么你可以这样:
SET LOCK_TIMEOUT 300000update SourceDB.dbo.gm_campaign_fb set next_time='9999-01-01' where next_time is null;
update SourceDB.dbo.gm_campaign_fb
set next_time=isnull((select MIN(login_time) from SourceDB.dbo.gm_campaign_fb where login_userid=a.login_userid and login_time>a.login_time),'9999-01-01')
from SourceDB.dbo.gm_campaign_fb a
where a.next_time='9999-01-01'