Herkese merhaba,

Bu yazıda SQL Server’da SQL Server Agent’ın son çalıştırma tarihi ve saatini listelemek ile ilgili bilgi vermeye çalışacağım.

SQL Server’da bazı durumlarda SQL Server Agent’ın son çalıştırma tarihi ve saatini listelemek isteyebilirsiniz.

Aşağıdaki kodu kullanarak siz de bu işlemi rahatlıkla yapabilirsiniz.

select j.job_id,
       j.name,
       js.step_id,
       js.step_name,
       last_run_outcome = case
                              when js.last_run_outcome = 0 then
                                  'Failed'
                              when js.last_run_outcome = 1 then
                                  'Succeeded'
                              when js.last_run_outcome = 2 then
                                  'Retry'
                              when js.last_run_outcome = 3 then
                                  'Canceled'
                              else
                                  'Unknown'
                          end,
       last_run_datetime = msdb.dbo.agent_datetime(   case
                                                          when js.last_run_date = 0 then
                                                              NULL
                                                          else
                                                              js.last_run_date
                                                      end,
                                                      case
                                                          when js.last_run_time = 0 then
                                                              NULL
                                                          else
                                                              js.last_run_time
                                                      end
                                                  )
from msdb.dbo.sysjobs j
    inner join msdb.dbo.sysjobsteps js
        on j.job_id = js.job_id;

Herkese çalışma hayatında ve yaşamında başarılar kolaylıklar.

166 Kez Okundu

Kategoriler: