RS First Dynamics NAV Blog


...from NAV 3.60 to NAV 2013
Archivio Posts
Anno 2015

Anno 2014

Anno 2013

Anno 2012

Anno 2011

Anno 2010

Anno 2009

Anno 2008

Anno 2007

Visualizzare informazioni sullo stato dei Jobs

Per recupare le informazioni sullo stato dei job andremo ad utilzzare la procedura sp_help_job, inserendo il suo risultato in una tabella temporanea.

Dovendo utilizzare la funzione openrowset, dobbiamo consentire a SQL Server di fare riferimento ad origini di dati OLE DB.
Quindi, come prima cosa, dobbiamo consentire la visualizzazione delle opzioni avanzate andando ad impostare il parametro "show advanced options" ad 1.

-- Consento la visualizzazione delle opzioni avanzate
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
-- Consento l'utilizzo della funzione openrowset
EXEC sp_configure 'Ad Hoc Distributed Queries', 1
RECONFIGURE
GO

-- Controllo se esiste la tabella di appoggio
if object_id('tempdb..#temp_sp_help_job') is not null
drop table #temp_sp_help_job

/*
Costruisco la tabella di apoggio tramite:
- openrowset
- exec msdb.dbo.sp_help_job
*/
select *
into #temp_sp_help_job
from openrowset ('sqloledb', 'server=<istanzaSqlServer>;trusted_connection=yes', 'set fmtonly off exec msdb.dbo.sp_help_job')

/* Visualizzo i job, il loro nome ed il loro stato */
select
 [name] as [Job Name] ,
 case enabled when 1 then 'Yes' else 'No' end as Enabled,
  case current_execution_status
    when 1 then 'Executing'
    when 2 then 'Waiting for thread'
    when 3 then 'Between retries'
    when 4 then 'Idle'
    when 5 then 'Suspended'
    when 7 then 'Performing completion actions' end as [Job Status]
from #temp_sp_help_job

Categoria: Sql Server ALL
sabato, 28 apr 2007 Ore. 11.03

Messaggi collegati


Statistiche
  • Views Home Page: 451.622
  • Views Posts: 864.065
  • Views Gallerie: 0
  • n° Posts: 343
  • n° Commenti: 0
Copyright © 2002-2007 - Blogs 2.0
dotNetHell.it | Home Page Blogs
ASP.NET 2.0 Windows 2003