内存溢出 jb51.cc 通过创建新一个存储过程,在内部循环检查job的状态,当发现其执行成功之后,返回0。
以下为引用的内容: Create PROCEDURE [dbo].[Proc_GetStatus] AS BEGIN SET NOCOUNT ON DECLARE @xp_results table (job_ID UNIQUEIDENTIFIER NOT NulL, last_run_date INT NOT NulL, last_run_time INT NOT NulL, next_run_date INT NOT NulL, next_run_time INT NOT NulL, next_run_schedule_ID INT NOT NulL, requested_to_run INT NOT NulL, request_source INT NOT NulL, request_source_ID sysname ColLATE database_default NulL, running INT NOT NulL, current_step INT NOT NulL, current_retry_attempt INT NOT NulL, job_state INT NOT NulL) DECLARE @job_owner sysname SET @job_owner = SUSER_Sname() INSERT INTO @xp_results EXECUTE master.dbo.xp_sqlagent_enum_jobs 1,@job_owner DECLARE @IsJobRunning BIT SELECT @IsJobRunning = x.running FROM @xp_results x INNER JOIN msdb.dbo.sysjobs sj ON sj.job_ID = x.job_ID WHERE sj.name = N'utilization Gather And Process' --Insert your job's name between the single quotes while @IsJobRunning=1 begin WAITFOR DELAY '00:00:20' INSERT INTO @xp_results EXECUTE master.dbo.xp_sqlagent_enum_jobs 1,@job_owner SELECT @IsJobRunning = x.running FROM @xp_results x INNER JOIN msdb.dbo.sysjobs sj ON sj.job_ID = x.job_ID WHERE sj.name = N'utilization Gather And Process' --Insert your job's name between the single quotes end return 0 End |
总结
以上是内存溢出为你收集整理的如何判断Sql agent job 是否执行完成全部内容,希望文章能够帮你解决如何判断Sql agent job 是否执行完成所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)