使用SQL判断当前JOB是否在运行

 
         SELECT   @currentStatus   =  current_execution_status  FROM   OPENROWSET
        (
' sqloledb ' ' server=(local);trusted_connection=yes ' ' set fmtonly off exec msdb.dbo.sp_help_job @job_name =  '' WriteMsgOnTime ''' )

 

Value Description

0

Returns only those jobs that are not idle or suspended.

1

Executing.

2

Waiting for thread.

3

Between retries.

4

Idle.

5

Suspended.

7

Performing completion actions.

你可能感兴趣的:(sql,server,jobs)