From 012410bdef3e8e661817c252b028e0d3a7fb8b2a Mon Sep 17 00:00:00 2001 From: Chrissy LeMaire Date: Sat, 15 Jun 2024 05:52:36 +0200 Subject: [PATCH] 2.1.18 --- bin/dbatools-index.json | Bin 8887024 -> 8887360 bytes .../SQLServerDiagnosticQueries_2012.sql | 14 ++++++++++---- .../SQLServerDiagnosticQueries_2014.sql | 14 ++++++++++---- .../SQLServerDiagnosticQueries_2016.sql | 14 ++++++++++---- .../SQLServerDiagnosticQueries_2016SP2.sql | 14 ++++++++++---- .../SQLServerDiagnosticQueries_2017.sql | 14 ++++++++++---- .../SQLServerDiagnosticQueries_2019.sql | 17 ++++++++++++----- .../SQLServerDiagnosticQueries_2022.sql | 14 ++++++++++---- dbatools.psd1 | 2 +- 9 files changed, 73 insertions(+), 30 deletions(-) diff --git a/bin/dbatools-index.json b/bin/dbatools-index.json index ab6987c2f299415524d1ddd703a4ca50b4f1a401..36396eb3303ee515d04719fcaafd751c97752c65 100644 GIT binary patch delta 715 zcma*h%TE(g6bA6y&M1flXGWxokD_9I0ZtKA1Qi4o(LuyV74ZR-0%~ccsMIIwS6#T% z#n}J7o|&G|$Kin&8g$IV zeB>b?3s8WC@SzYzSOfzmEG$MbmY@WFEX6XEVmVe|B~~GTGOWfLtVKE2A&B+ZfQ{IM z&8R>ns;~t%La4@8)SwpIupK*4hn=WL19o9I_Mj0>*o$VgU?2A509tVnZ8(I(ubjz@ z%!V~fkgBvK_@uN*zI^P;m(MA!M83~B4Kml=Ss=bQX+!Ktl`d27J9Kw0<4k-1{qN;F zC#r>1wHwGfZ@uz0tQmjJH+$5mDpRej7%Qogt~uj0do)|w()7Uz6vot$il|}s0X68p z7;D$Ol87dr|Nk`8BiYA}CApeLLo&s2pG*Z4dS0!nQzXx3Tl}FoH}vz6BzvFwl_E^N zOi`wh-*10jVouio@Q9uEw>>q=tw-6ML+x~gI_M~M(lI(tC+H-F=@gx&E;>Wqbe7K1 zdAdM7)JuI7p?-?e01eU*U8GBNnPN0daZ1n?8lfbO(p9=f*J+GWbc1fvExJv2=q`=Z RJ-Sa12$XiSxrY^>egcYYGX4Mn delta 536 zcmZ|F$xc&o0EO|}_96wUUa^1!A}T5ZMW|3MqE-P1^g5x;;4IG6dDfy|%L9<`-w_u+ zg66uZwh2pZ`UpOPF)?xB!V~u{e&6Pt+@}Tm$HxUbg%3XgY)V){DM898r-BemS;lf4 zR#3@G!coNYBh9s5AshVdn=AgZz0Xt0_rCwW=NprD zMVHlS#jSt!^4VaC-?XJ``sbX6%Gq$ymE&?kPRc1cEdz2!&dQ(+$*_#bsEo+aJN2Vnycjcbkmk07t9?4^QB2VR+JeL>pQeMex SNy&`7k+*`Ry>Kzp^7StQAl3^2 diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2012.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2012.sql index dc8d0ce1b7..c13dc7dc97 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2012.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2012.sql @@ -1,7 +1,7 @@ -- SQL Server 2012 Diagnostic Information Queries -- Glenn Berry --- Last Modified: June 3, 2024 +-- Last Modified: June 14, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -365,10 +365,10 @@ ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); -- Get SQL Server Agent jobs and Category information (Query 10) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], sc.name AS [CategoryName], SUSER_SNAME(sj.owner_sid) AS [Job Owner], -sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], -sj.notify_email_operator_id, sj.notify_level_email, h.run_status, +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], h.run_status, +CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date], RIGHT(STUFF(STUFF(REPLACE(STR(h.run_duration, 7, 0), ' ', '0'), 4, 0, ':'), 7, 0, ':'),8) AS [Last Duration - HHMMSS], -CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date] +s.[name] AS [Schedule Name], s.[enabled] AS [Schedule Enabled], js.next_run_date, js.next_run_time FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) @@ -380,6 +380,12 @@ ON sj.category_id = sc.category_id LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_id +LEFT OUTER JOIN msdb.dbo.sysjobs_view AS jv WITH (NOLOCK) +ON jv.job_id = sj.job_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON jv.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON s.schedule_id = js.schedule_id ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); ------ diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2014.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2014.sql index 72c237e65f..55706f6d25 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2014.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2014.sql @@ -1,7 +1,7 @@ -- SQL Server 2014 Diagnostic Information Queries -- Glenn Berry --- Last Modified: June 3, 2024 +-- Last Modified: June 14, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -359,10 +359,10 @@ ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); -- Get SQL Server Agent jobs and Category information (Query 10) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], sc.name AS [CategoryName], SUSER_SNAME(sj.owner_sid) AS [Job Owner], -sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], -sj.notify_email_operator_id, sj.notify_level_email, h.run_status, +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], h.run_status, +CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date], RIGHT(STUFF(STUFF(REPLACE(STR(h.run_duration, 7, 0), ' ', '0'), 4, 0, ':'), 7, 0, ':'),8) AS [Last Duration - HHMMSS], -CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date] +s.[name] AS [Schedule Name], s.[enabled] AS [Schedule Enabled], js.next_run_date, js.next_run_time FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) @@ -374,6 +374,12 @@ ON sj.category_id = sc.category_id LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_id +LEFT OUTER JOIN msdb.dbo.sysjobs_view AS jv WITH (NOLOCK) +ON jv.job_id = sj.job_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON jv.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON s.schedule_id = js.schedule_id ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); ------ diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2016.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2016.sql index fb8e02dc53..ea1e8f7fde 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2016.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2016.sql @@ -1,7 +1,7 @@ -- SQL Server 2016 Diagnostic Information Queries -- Glenn Berry --- Last Modified: June 3, 2024 +-- Last Modified: June 14, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -341,10 +341,10 @@ ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); -- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], sc.name AS [CategoryName], SUSER_SNAME(sj.owner_sid) AS [Job Owner], -sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], -sj.notify_email_operator_id, sj.notify_level_email, h.run_status, +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], h.run_status, +CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date], RIGHT(STUFF(STUFF(REPLACE(STR(h.run_duration, 7, 0), ' ', '0'), 4, 0, ':'), 7, 0, ':'),8) AS [Last Duration - HHMMSS], -CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date] +s.[name] AS [Schedule Name], s.[enabled] AS [Schedule Enabled], js.next_run_date, js.next_run_time FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) @@ -356,6 +356,12 @@ ON sj.category_id = sc.category_id LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_id +LEFT OUTER JOIN msdb.dbo.sysjobs_view AS jv WITH (NOLOCK) +ON jv.job_id = sj.job_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON jv.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON s.schedule_id = js.schedule_id ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); ------ diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2016SP2.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2016SP2.sql index 7232846b1e..df9a137508 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2016SP2.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2016SP2.sql @@ -1,7 +1,7 @@ -- SQL Server 2016 SP2 Diagnostic Information Queries -- Glenn Berry --- Last Modified: June 3, 2024 +-- Last Modified: June 14, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -323,10 +323,10 @@ ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); -- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], sc.name AS [CategoryName], SUSER_SNAME(sj.owner_sid) AS [Job Owner], -sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], -sj.notify_email_operator_id, sj.notify_level_email, h.run_status, +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], h.run_status, +CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date], RIGHT(STUFF(STUFF(REPLACE(STR(h.run_duration, 7, 0), ' ', '0'), 4, 0, ':'), 7, 0, ':'),8) AS [Last Duration - HHMMSS], -CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date] +s.[name] AS [Schedule Name], s.[enabled] AS [Schedule Enabled], js.next_run_date, js.next_run_time FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) @@ -338,6 +338,12 @@ ON sj.category_id = sc.category_id LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_id +LEFT OUTER JOIN msdb.dbo.sysjobs_view AS jv WITH (NOLOCK) +ON jv.job_id = sj.job_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON jv.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON s.schedule_id = js.schedule_id ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); ------ diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2017.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2017.sql index 23d11e79de..fae3ef26d9 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2017.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2017.sql @@ -1,7 +1,7 @@ -- SQL Server 2017 Diagnostic Information Queries -- Glenn Berry --- Last Modified: June 3, 2024 +-- Last Modified: June 14, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -344,10 +344,10 @@ ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); -- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], sc.name AS [CategoryName], SUSER_SNAME(sj.owner_sid) AS [Job Owner], -sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], -sj.notify_email_operator_id, sj.notify_level_email, h.run_status, +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], h.run_status, +CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date], RIGHT(STUFF(STUFF(REPLACE(STR(h.run_duration, 7, 0), ' ', '0'), 4, 0, ':'), 7, 0, ':'),8) AS [Last Duration - HHMMSS], -CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date] +s.[name] AS [Schedule Name], s.[enabled] AS [Schedule Enabled], js.next_run_date, js.next_run_time FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) @@ -359,6 +359,12 @@ ON sj.category_id = sc.category_id LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_id +LEFT OUTER JOIN msdb.dbo.sysjobs_view AS jv WITH (NOLOCK) +ON jv.job_id = sj.job_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON jv.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON s.schedule_id = js.schedule_id ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); ------ diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2019.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2019.sql index c0f55ce5f2..f718ff9636 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2019.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2019.sql @@ -1,7 +1,7 @@ -- SQL Server 2019 Diagnostic Information Queries -- Glenn Berry --- Last Modified: June 3, 2024 +-- Last Modified: June 14, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -100,7 +100,8 @@ SELECT @@SERVERNAME AS [Server Name], @@VERSION AS [SQL Server and OS Version In -- 15.0.4345.5 CU24 12/14/2023 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate24 -- 15.0.4355.3 CU25 2/15/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate25 -- 15.0.4360.2 CU25 + GDR 4/9/2024 https://support.microsoft.com/en-us/topic/kb5036335-description-of-the-security-update-for-sql-server-2019-cu25-april-9-2024-eb3571d0-62ee-445e-9681-5715caf9bbc2 --- 15.0.4365.2 CU26 4/11/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate26 +-- 15.0.4365.2 CU26 4/11/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate26 +-- 15.0.4375.4 CU27 6/13/2024 https://learn.microsoft.com/en-us/troubleshoot/sql/releases/sqlserver-2019/cumulativeupdate27 -- How to determine the version, edition and update level of SQL Server and its components -- https://bit.ly/2oAjKgW @@ -328,10 +329,10 @@ ORDER BY d.recovery_model_desc, d.[name] OPTION (RECOMPILE); -- Get SQL Server Agent jobs and Category information (Query 9) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], sc.name AS [CategoryName], SUSER_SNAME(sj.owner_sid) AS [Job Owner], -sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], -sj.notify_email_operator_id, sj.notify_level_email, h.run_status, +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], h.run_status, +CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date], RIGHT(STUFF(STUFF(REPLACE(STR(h.run_duration, 7, 0), ' ', '0'), 4, 0, ':'), 7, 0, ':'),8) AS [Last Duration - HHMMSS], -CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date] +s.[name] AS [Schedule Name], s.[enabled] AS [Schedule Enabled], js.next_run_date, js.next_run_time FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) @@ -343,6 +344,12 @@ ON sj.category_id = sc.category_id LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_id +LEFT OUTER JOIN msdb.dbo.sysjobs_view AS jv WITH (NOLOCK) +ON jv.job_id = sj.job_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON jv.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON s.schedule_id = js.schedule_id ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); ------ diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2022.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2022.sql index 4336b70506..533a98ea0f 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2022.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2022.sql @@ -1,7 +1,7 @@ -- SQL Server 2022 Diagnostic Information Queries -- Glenn Berry --- Last Modified: June 3, 2024 +-- Last Modified: June 14, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -328,10 +328,10 @@ FROM sys.dm_server_accelerator_status WITH (NOLOCK) OPTION (RECOMPILE); -- Get SQL Server Agent jobs and Category information (Query 10) (SQL Server Agent Jobs) SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], sc.name AS [CategoryName], SUSER_SNAME(sj.owner_sid) AS [Job Owner], -sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], -sj.notify_email_operator_id, sj.notify_level_email, h.run_status, +sj.date_created AS [Date Created], sj.[enabled] AS [Job Enabled], h.run_status, +CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date], RIGHT(STUFF(STUFF(REPLACE(STR(h.run_duration, 7, 0), ' ', '0'), 4, 0, ':'), 7, 0, ':'),8) AS [Last Duration - HHMMSS], -CONVERT(DATETIME, RTRIM(h.run_date) + ' ' + STUFF(STUFF(REPLACE(STR(RTRIM(h.run_time),6,0),' ','0'),3,0,':'),6,0,':')) AS [Last Start Date] +s.[name] AS [Schedule Name], s.[enabled] AS [Schedule Enabled], js.next_run_date, js.next_run_time FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) @@ -343,6 +343,12 @@ ON sj.category_id = sc.category_id LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_id +LEFT OUTER JOIN msdb.dbo.sysjobs_view AS jv WITH (NOLOCK) +ON jv.job_id = sj.job_id +LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) +ON jv.job_id = js.job_id +LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) +ON s.schedule_id = js.schedule_id ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); ------ diff --git a/dbatools.psd1 b/dbatools.psd1 index a8999f1027..5f52e71240 100644 --- a/dbatools.psd1 +++ b/dbatools.psd1 @@ -11,7 +11,7 @@ RootModule = 'dbatools.psm1' # Version number of this module. - ModuleVersion = '2.1.17' + ModuleVersion = '2.1.18' # ID used to uniquely identify this module GUID = '9d139310-ce45-41ce-8e8b-d76335aa1789'