J'ai un table qui trace les lancements de batchs et je cherche à déterminer à quelle fréquence ces batchs sont lancés.
Si je me concentre sur l'un d'eux :
Select Distinct
pt.PROCESS_NAME As PROCESS_NAME
, Convert(VARCHAR,pt.START_DT,24) As START_TIME
From PROCESS_TRACE As pt
Where pt.PROCESS_NAME = 'AuditFax'
Order By pt.PROCESS_NAME ASC, START_TIME ASC
pour moi tu dois passer par une table temporaire qui aura un champ identity et deux champs date (start_time et Next_start_time)
du style
Select Distinct
ID = IDENTITY(INT,1,1)
, pt.PROCESS_NAME As PROCESS_NAME
, START_TIME
, NEXT_START_TIME = START_TIME /* pour initialiser bidon mais avoir le bon type*/
into #tmp
From PROCESS_TRACE As pt
Where pt.PROCESS_NAME = 'AuditFax'
Order By START_TIME ASC
select t1.PROCESS_NAME,ecart=datediff(ms,t2.NEXT_START_TIME,t1.START_TIME)
from #tmp t1,#tmp t2
where t2.ID = t1.ID + 1
drop table #tmp
Attention je ne l'ai pas testée.
Bonne journée
Faites simple, aussi simple que possible, mais pas simpliste.
A. Einstein.