https://dotblogs.com.tw/rainmaker/2015/02/02/148355

select a.[name]
from openrowset('SQLNCLI', 'Server=localhost;Trusted_Connection=yes;',
'SET NOCOUNT ON;SET FMTONLY OFF;exec msdb..sp_help_job') AS a
where [name] in ('JOB-113720-CTLFZ_1',
				'JOB-113720-CTLFZ_2',
				'JOB-113720-CTLFZ_3')
and current_execution_status=4

 

--建立一個 LinkedServer 連自已
sp_addlinkedserver @server = 'LOCALSERVER',  @srvproduct = '', @provider = 'SQLOLEDB', @datasrc = @@servername

select a.[name]
FROM OPENQUERY(LOCALSERVER, 'EXEC(''exec msdb..sp_help_job'')')a
where [name] in ('JOB-113720-CTLFZ_1',
				'JOB-113720-CTLFZ_2',
				'JOB-113720-CTLFZ_3')
and current_execution_status=4