Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (29 sloc) 1.53 KB
DECLARE @m int
set @m = DATEDIFF(mi,SYSUTCDATETIME(), SYSDATETIME())
SELECT
CASE
WHEN [BATCHHISTORY].[STATUS] = 3 THEN N'Error'
WHEN [BATCHHISTORY].[STATUS] = 4 THEN N'Finished'
WHEN [BATCHHISTORY].[STATUS] = 8 THEN N'Canceled'
ELSE CONVERT(nvarchar, [BATCHHISTORY].[STATUS])
END as [STATUS]
,[BATCHJOBHISTORY].[CAPTION] as [BatchCaption]
,[BATCHHISTORY].[CAPTION] as [TaskCaption]
,DATEADD(minute, @m, ORIGSTARTDATETIME) as [ORIGSTARTDATETIME]
,DATEADD(minute, @m, [BATCHHISTORY].[STARTDATETIME]) as [STARTDATETIME]
,DATEDIFF(mi, [BATCHJOBHISTORY].ORIGSTARTDATETIME, [BATCHJOBHISTORY].STARTDATETIME) as [StartDelayMin]
,DATEADD(minute, @m, [BATCHHISTORY].[ENDDATETIME]) as [ENDDATETIME]
,DATEDIFF(ss, [BATCHHISTORY].STARTDATETIME, [BATCHHISTORY].enddatetime) as [DurationSec]
,[BATCHHISTORY].[COMPANY]
,[BATCHHISTORY].[BATCHJOBID]
,[BATCHHISTORY].SERVERID
,(SELECT TOP 1 [Name] FROM [DynamicsAXProd_model].[dbo].[ModelElement] where axid = [BATCHHISTORY].CLASSNUMBER and ElementType = 45) as ClassName
,[BATCHHISTORY].CLASSNUMBER
,[ALERTSPROCESSED]
,[BATCHCREATEDBY]
,[CANCELEDBY]
FROM [dbo].[BATCHJOBHISTORY], [dbo].[BATCHHISTORY]
where
[BATCHHISTORY].BATCHJOBHISTORYID = [BATCHJOBHISTORY].RECID and
DATEDIFF(mi, [BATCHJOBHISTORY].ORIGSTARTDATETIME, [BATCHJOBHISTORY].STARTDATETIME) > 2 and
DATEADD(minute, @m, [BATCHJOBHISTORY].[STARTDATETIME]) > CONVERT(datetime, '2019-12-12', 120)
You can’t perform that action at this time.