Hi all ,
we have a requirement to find the job count which have executed in the previous month.
is der a query or utility through which this can be done
Find jobs ran for previous month
Re: Find jobs ran for previous month
Hi Anirudh,
You can try the below SQL query to find the list of jobs that executed (irrespective of failure or successful execution of the job) for the previous month.
SELECT [APPLGROUP]
,[SCHEDTAB]
,[NODEID]
,[ODATE]
,[OSCOMPMSG]
,[JOBNAME]
FROM [ctrlm700].[dbo].[CMR_AJF]
WHERE
(STATUS = 'Y'
OR
STATUS = 'N')
AND
STATE = '8'
AND
ODATE >= ( select DATEADD(MONTH, DATEDIFF(MONTH, 0,GETDATE()) - 1, 0) )
AND
ODATE <= ( select dateadd(month,datediff(month,0,GETDATE()),0) )
And below SQL query to find the list of jobs that executed successfully for the previous month:
SELECT [APPLGROUP]
,[SCHEDTAB]
,[NODEID]
,[ODATE]
,[OSCOMPMSG]
,[JOBNAME]
FROM [ctrlm700].[dbo].[CMR_AJF]
WHERE
STATUS = 'Y'
AND
STATE = '8'
AND
ODATE >= ( select DATEADD(MONTH, DATEDIFF(MONTH, 0,GETDATE()) - 1, 0) )
AND
ODATE <= ( select dateadd(month,datediff(month,0,GETDATE()),0) )
Regards,
Ankit
You can try the below SQL query to find the list of jobs that executed (irrespective of failure or successful execution of the job) for the previous month.
SELECT [APPLGROUP]
,[SCHEDTAB]
,[NODEID]
,[ODATE]
,[OSCOMPMSG]
,[JOBNAME]
FROM [ctrlm700].[dbo].[CMR_AJF]
WHERE
(STATUS = 'Y'
OR
STATUS = 'N')
AND
STATE = '8'
AND
ODATE >= ( select DATEADD(MONTH, DATEDIFF(MONTH, 0,GETDATE()) - 1, 0) )
AND
ODATE <= ( select dateadd(month,datediff(month,0,GETDATE()),0) )
And below SQL query to find the list of jobs that executed successfully for the previous month:
SELECT [APPLGROUP]
,[SCHEDTAB]
,[NODEID]
,[ODATE]
,[OSCOMPMSG]
,[JOBNAME]
FROM [ctrlm700].[dbo].[CMR_AJF]
WHERE
STATUS = 'Y'
AND
STATE = '8'
AND
ODATE >= ( select DATEADD(MONTH, DATEDIFF(MONTH, 0,GETDATE()) - 1, 0) )
AND
ODATE <= ( select dateadd(month,datediff(month,0,GETDATE()),0) )
Regards,
Ankit