- mari,
bonjour,
j’ai fais une requête pour l’historique de traitement de mes jobs
et je veux introduire dans ma requête pour avoir une clé unique pour identifier les étapes traitées le même jour pour un job
voici ma requête
SELECT
J.name AS nomJob,
CONVERT(sysname, SUSER_SNAME(j.owner_sid)) as proprietaire,
S.step_id AS numeroEtapeJob,
S.step_name AS nomEtapeJob,
CONVERT(VARCHAR(19), CONCAT(CONVERT(date,convert(varchar(10), H.run_date, 103)), ' ',
CONVERT(VARCHAR(8), CAST(STUFF(STUFF(RIGHT('000000' + CONVERT(VARCHAR(8), H.run_time), 6), 5, 0, ':'), 3, 0, ':') AS TIME), 108))) AS Date_Execution_Etape,
CASE LEN(CAST(H.run_duration AS VARCHAR(10)))
WHEN 1 THEN '00:00:0' + CAST(H.run_duration AS CHAR(1))
WHEN 2 THEN '00:00:' + CAST(H.run_duration AS CHAR(2))
WHEN 3 THEN '00:0' + STUFF(CAST(H.run_duration AS CHAR(3)), 2, 0, ':')
WHEN 4 THEN '00:' + STUFF(CAST(H.run_duration AS CHAR(4)), 3, 0, ':')
WHEN 5 THEN '0' + STUFF(STUFF(CAST(H.run_duration AS CHAR(5)), 2, 0, ':'), 5, 0, ':')
WHEN 6 THEN STUFF(STUFF(CAST(H.run_duration AS CHAR(6)), 3, 0, ':'), 6, 0, ':')
END AS dureeExecutionEtape,
CASE H.run_status
WHEN 0 THEN 'échec'
WHEN 1 THEN 'Succés'
WHEN 2 THEN 'A reprendre'
WHEN 3 THEN 'annulé'
WHEN 4 THEN 'en cours'
END AS 'EtatDexecution'
FROM msdb.dbo.sysjobs AS J
INNER JOIN msdb.dbo.sysjobsteps AS S
ON J.job_id = S.job_id
INNER JOIN msdb.dbo.sysjobhistory AS H
ON S.job_id = H.job_id
AND S.step_id = H.step_id
ORDER BY Date_Execution_Etape DESC
Pourrais vous m’aider svp
+0
-0