-- -- To See the run history of a solution/ solutions -- -- Rev Who Comment -- 01 CB Optimised declare @DateFrom datetime declare @DateTo datetime declare @SolutionName nvarchar(200) declare @SolutionName2 nvarchar(200) declare @SolutionName3 nvarchar(200) set @DateFrom = dateadd(dd,-180,getdate() ) set @DateTo = NULL declare @runidFrom int select @runidFrom = MAX(runid) from CADIS_SYS.CO_PROCESSHISTORY where runstart < isnull(@DateFrom, '2099-12-31 23:59:59' ) set @SolutionName = '4 Master ' -- set @SolutionName2 = '' -- set @SolutionName3 = '' -- set @SolutionName3 = '%Industry%' ;with cte_jobs as (SELECT H1.runid, Name, datename(WeekDay,H1.RUNSTART) as StartDay -- ,datename(WeekDay,(dateadd(Hour,8,H1.RUNSTART))) as StartDaySG -- ,dateadd(Hour,8,H1.RUNSTART) as StartSG ,H1.RUNSTART, H1.RUNEND, H1.RUNSUCCESSFUL ,right('00' + convert(nvarchar(2),datename(hh,H1.RUNSTART)),2)+':' + right('00' + convert(nvarchar(2),datename(mi,H1.RUNSTART)),2) as startTime ,H1.LAUNCHEDBY --,datediff(MI,H1.RunStart, H1.RunEnd) as Duration --,datediff(SS,H1.RunStart, H1.RunEnd) as DurationSeconds ,RIGHT('0' + CAST(datediff(SS,H1.RunStart, H1.RunEnd) / 3600 AS VARCHAR),2) + ':' + RIGHT('0' + CAST((datediff(SS,H1.RunStart, H1.RunEnd) / 60) % 60 AS VARCHAR),2) + ':' + RIGHT('0' + CAST(datediff(SS,H1.RunStart, H1.RunEnd) % 60 AS VARCHAR),2) as RunDuration FROM CADIS_SYS.CO_PROCESSHISTORY H1 INNER JOIN ( SELECT * FROM CADIS_SYS.CO_PROCESSHISTORY where runid > @runidFrom and runstart > @DateFrom and runstart < isnull(@DateTo, '2099-12-31 23:59:59' ) ) H2 ON H2.COMPONENTID = H1.COMPONENTID AND H2.GUID = H1.GUID AND H2.RUNID = H1.RUNID INNER JOIN CADIS_SYS.VW_ALL_PROCESSES ap on ap.GUID = H1.GUID) select * from cte_jobs where (Name like @SolutionName or Name like @SolutionName2 or Name like @SolutionName3 ) order by Runstart desc
Here are some of the more useful bits of SQL I have crafted or adapted to interrogate the MARKIT EDM schema. Mostly useful for impact analysis. At the moment I am working on version 8. I can not guarantee if the SQL will work on later versions. If you do find problems let me know.
Thursday, 28 January 2016
SQL to show the run history of a solution/ solutions
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment