You are on page 1of 4

Select distinct instancetime, c.name, b.resourcename, SLE.

terminationreason

from [dbo].[BPAScheduleLogEntry] AS SLE

join [BPAScheduleLog] AS SL on SLE.schedulelogid = SL.id

join [BPASchedule] AS S on S.id = SL.scheduleid

join [dbo].[BPATaskSession] b on b.taskid = sle.taskid

join BPAProcess as c on c.processid= b.processid

where SLE.terminationreason is not null and

(SLE.terminationreason like '%is too busy to run that process.%' or


SLE.terminationreason like '%No sessions were successfully created%' or
SLE.terminationreason like '%offline%' or SLE.terminationreason like '%effective%'
or SLE.terminationreason like '%Timeout expired%'
or SLE.terminationreason like '%Session creation failed%' or SLE.terminationreason
like '%Timed out%')
and instancetime between '2021-04-23 18:30:00' and '2021-04-24 01:59:59'

complete report count

with cte_raw as (
SELECT SessionNumber = SESSIONTABLE.sessionnumber,
ProcessName_Session = SESSIONTABLE.processname,
ProcessName = SESSIONTABLE.processname,
ProcessStartTime = SESSIONTABLE.startdatetime,
ProcessEndTime = SESSIONTABLE.enddatetime,
ProcessExecutedOn = SESSIONTABLE.runningresourcename,
ProcessExecutedBy = SESSIONTABLE.starterusername,
ProcessStatus = STATUSINFO.description,
StartupParams = SESSIONTABLE.startparamsxml
FROM BPVSessionInfo (NOLOCK) SESSIONTABLE
LEFT JOIN BPAStatus (NOLOCK) STATUSINFO
ON SESSIONTABLE.statusid = STATUSINFO.statusid
WHERE SESSIONTABLE.runningresourcename NOT Like '%_debug%'
AND SESSIONTABLE.enddatetime between CAST(CAST(GETDATE() - 1 AS DATE) AS
DATETIME) AND CAST(CAST(GETDATE() AS DATE) AS DATETIME))

select Environment = 'Azure PRD', DateNumber,


MasterProcess = ProcessName_Session,
SubProcess = ProcessName,
Total = count(1),
Completed = sum(completed),
Terminated = sum(terminated),
Stopped = sum(stopped),
Running = sum(running),
ReRun = sum(rerun),'',
TotalRunHours = SUM(TotalRunTimeInSeconds),
TotalSuccessHours =
SUM(TotalSuccessRunTimeInSeconds),
TotalTerminatedHours =
SUM(TotalTerminatedRunTimeInSeconds),
TotalStoppedHours =
SUM(TotalStoppedRunTimeInSeconds)
from (
select DateNumber = convert(varchar(10), ProcessEndTime, 112),
ProcessName_Session,
ProcessName,
Completed = case when ProcessStatus = 'Completed' then 1
else 0 end,
Terminated = case when ProcessStatus = 'Terminated' then 1
else 0 end,
Stopped = case when ProcessStatus = 'Stopped' then 1 else 0
end,
Running = case when ProcessStatus = 'Running' then 1 else 0
end,
ReRun = case when ProcessExecutedBy in ('[Scheduler]',
'Email.Architecture') then 0 else 1 end,
TotalRunTimeInSeconds = ((DATEPART(dd, ProcessEndTime -
ProcessStartTime) - 1)* 24 * 60 * 60) + (DATEPART(hh, ProcessEndTime -
ProcessStartTime) * 60 * 60) + (DATEPART(mi, ProcessEndTime - ProcessStartTime) *
60) + (DATEPART(s, ProcessEndTime - ProcessStartTime)),
TotalSuccessRunTimeInSeconds = case when ProcessStatus =
'Completed' then ((DATEPART(dd, ProcessEndTime - ProcessStartTime) - 1)* 24 * 60 *
60) + (DATEPART(hh, ProcessEndTime - ProcessStartTime) * 60 * 60) + (DATEPART(mi,
ProcessEndTime - ProcessStartTime) * 60) + (DATEPART(s, ProcessEndTime -
ProcessStartTime)) else 0 end,
TotalTerminatedRunTimeInSeconds = case when ProcessStatus =
'Terminated' then ((DATEPART(dd, ProcessEndTime - ProcessStartTime) - 1)* 24 * 60 *
60) + (DATEPART(hh, ProcessEndTime - ProcessStartTime) * 60 * 60) + (DATEPART(mi,
ProcessEndTime - ProcessStartTime) * 60) + (DATEPART(s, ProcessEndTime -
ProcessStartTime)) else 0 end,
TotalStoppedRunTimeInSeconds = case when ProcessStatus =
'Stopped' then ((DATEPART(dd, ProcessEndTime - ProcessStartTime) - 1)* 24 * 60 *
60) + (DATEPART(hh, ProcessEndTime - ProcessStartTime) * 60 * 60) + (DATEPART(mi,
ProcessEndTime - ProcessStartTime) * 60) + (DATEPART(s, ProcessEndTime -
ProcessStartTime)) else 0 end
from cte_raw) a
group by DateNumber, ProcessName_Session, ProcessName
order by 1, 2, 3

-----------------------------------------------------------------------------------
---

DECLARE @StartDate DATETIME


DECLARE @EndDate DATETIME

SET @StartDate = '2021-04-23 18:30:00' /*Change the date time here'*/


SET @EndDate = '2021-04-24 01:59:59' /*Change the date time here'*/
select a.sessionnumber, a.processname, b.description, a.startdatetime,
a.enddatetime,a.starterusername,runningresourcename
from BPVSessionInfo (nolock) a
left join BPAStatus (nolock) b
on a.statusid = b.statusid
left join BPASessionLog_Unicode (nolock) c
on a.sessionnumber = c.sessionnumber
where runningresourcename not like '%debug%' and description like
'%terminated%'

--and a.enddatetime between cast(getdate() -1 as date) and


CAST(getdate() as date)
and a.enddatetime between @StartDate and @EndDate
group by a.sessionnumber, a.processname, b.description, a.startdatetime,
a.enddatetime,a.starterusername,runningresourcename
--and b.description = 'Terminated'
--and left(result, 5) = 'ERROR'

order by a.enddatetime desc

-------------------------------------------------
select runningresourcename,a.starterusername,a.processname, b.description
, a.startdatetime , a.enddatetime,C.objectname,c.stagename, c.result,
c.startdatetime as cstartdatetime
from BPVSessionInfo (nolock) a
left join BPAStatus (nolock) b
on a.statusid = b.statusid
left join BPASessionLog_Unicode (nolock) c
on a.sessionnumber = c.sessionnumber
where runningresourcename not like '%debug%'
and a.enddatetime between paste date
and b.description = 'Terminated'
and left(result, 5) = 'ERROR'
-----------------------------------------------------------------------------------
--

join BPAProcess as c on c.processid= b.processid

where SLE.terminationreason is not null and

/*(SLE.terminationreason like '%is too busy to run that process.%' or


SLE.terminationreason like '%No sessions were successfully created%' or
SLE.terminationreason like '%offline%' or SLE.terminationreason like '%effective%'
or SLE.terminationreason like '%Timeout expired%'
or SLE.terminationreason like '%Session creation failed%' or SLE.terminationreason
like '%Timed out%')
and*/
instancetime between '2021-04-23 15:00:00' and '2021-04-24 01:59:59'
-----------------------------------------------------------------------------------
-------------------------
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = '2020-08-21 00:00:00' /*Change the date time here'*/
SET @EndDate = '2020-08-23 23:59:59' /*Change the date time here'*/
select a.sessionnumber, runningresourcename,
a.starterusername,a.processname, b.description, a.startdatetime,
a.enddatetime,C.objectname,c.stagename, c.result, c.startdatetime
from BPVSessionInfo (nolock) a
left join BPAStatus (nolock) b
on a.statusid = b.statusid
left join BPASessionLog_Unicode (nolock) c
on a.sessionnumber = c.sessionnumber
where runningresourcename not like '%debug%'
--and a.enddatetime between cast(getdate() -1 as date) and
CAST(getdate() as date)
and a.enddatetime between @StartDate and @EndDate
and b.description = 'Terminated'
and left(result, 5) = 'ERROR'
order by 4,11 asc
-----------------------------------------------------------------------------------
-------------------
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = '2021-04-29 06:00:00' /*Change the date time here'*/
SET @EndDate = '2021-04-29 7:00:00'
select * from BPAAuditEvents

You might also like