From 2d35be306005ca247341ac4fdcea5fb1c87b93b7 Mon Sep 17 00:00:00 2001 From: Chrissy LeMaire Date: Fri, 8 Mar 2024 19:51:27 +0100 Subject: [PATCH] 2.1.9 --- bin/dbatools-index.json | Bin 8878218 -> 8880752 bytes .../SQLServerDiagnosticQueries_2008.sql | 28 +++++++++++------- .../SQLServerDiagnosticQueries_2008R2.sql | 28 +++++++++++------- .../SQLServerDiagnosticQueries_2012.sql | 8 ++--- .../SQLServerDiagnosticQueries_2014.sql | 8 ++--- .../SQLServerDiagnosticQueries_2016.sql | 8 ++--- .../SQLServerDiagnosticQueries_2016SP2.sql | 8 ++--- .../SQLServerDiagnosticQueries_2017.sql | 8 ++--- .../SQLServerDiagnosticQueries_2019.sql | 8 ++--- .../SQLServerDiagnosticQueries_2022.sql | 8 ++--- dbatools.psd1 | 2 +- 11 files changed, 63 insertions(+), 51 deletions(-) diff --git a/bin/dbatools-index.json b/bin/dbatools-index.json index 4d887d20fb40abda622f175852da3e5f5ab32811..0af6922f81f7ada219b7ab2313d7cab44a3ce720 100644 GIT binary patch delta 1096 zcmZY7OKeP07zgk(dWTlgX;r6>sa{GSwAE=l?VxHXRnObrse03*(}%XEFVCvM-+Mub z`4T~_bt58~B|96WJBbiP!oospWntleJLwP>zufb<=ljk%-?=t%UmM2*Ed(2;Ar2bs zn2s5UM*?Od5wkEGbC3iFl97VBNX0y)!HINaAQM?|Ash3N104&n5V=@{#mGZG3Q&k8 zSc)PPqXf%P3OCA7jtY2Ci7I%p94oLA)mViZtcDM3uoksghxMq#2GnCCHeoZiU@Nvg zHS+x7T>(vg9^djvN*j$O^3pU?6LnRr>Q$>6P#rQcYR)azm0xvmpiFsGrLv~Cs-vn` z4RUlqHFKt0b*jUhsZ^!%X}v8&9C=Ne{4yDGxZyxrmY)IF#MWD}7@TW*Rl7`FO?Jv) z*sCW6InuA%7$?B^{qnxXER=`i6<5T!*!@_ZzpKlP+-x%5R>;TP?eX$s)C|o2KbAeZ zcp_wYWZKy{T^#)z=ZIs-uF2S&D$W1*S&Ep;+DWS_S6)@2{`5V{&HeuAyC>T{Jf$br zivG_rNxoQ`Eg^q>;P%+cTlUF_V%t_!8-Bf7tDU;IqJL6F6Hg_I_N+8hNvyAx!b;GW zY>vwFnKfEM?AqnotIz@ohI|DQtX|{_U(a#K&2?Gv^73nKYC_Lch2*Sg8HpFGo6e>zv_e%bTZh6lT5PMPBuC0U?;ic zv5Vcf$Y&3GDPSLN3h}U?BD@^nAjOn$h{O0eLMcZnqnrwkahwxWa*|V2QO#-m)KJSA z&T@_bb<}g71}<=sO9Z)0BTY2ZLMtKKxWd&>#uu^SAF1xo>qY()`*owyZKEqLmtAvv zgULT#CQ+RXXZHS1x0UUt)JChk-)ub4=19I@GQl+ab3OEBYkcGy$W0lLLAfQj<&F%= zu-uhW3~$MQs;%A`D#=kh|PWLjqArOZl9UP)Z$Bq8&HyiR&n I-*o=k1Ot@9QUCw| diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2008.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2008.sql index 0d7f5278be..fde9f5897a 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2008.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2008.sql @@ -1,7 +1,7 @@ -- SQL Server 2008 Diagnostic Information Queries -- Glenn Berry --- Last Modified: January 3, 2023 +-- Last Modified: March 6, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -14,7 +14,7 @@ -- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server --****************************************************************************** ---* Copyright (C) 2023 Glenn Berry +--* Copyright (C) 2024 Glenn Berry --* All rights reserved. --* --* @@ -141,18 +141,24 @@ SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly]; -- Get SQL Server Agent jobs and Category information (Query 4) (SQL Server Agent Jobs) -SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner], +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, sc.name AS [CategoryName], -s.[enabled] AS [Sched Enabled], js.next_run_date, js.next_run_time +sj.notify_email_operator_id, sj.notify_level_email, h.run_status, +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] FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) -INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +LEFT OUTER JOIN + (SELECT job_id, instance_id = MAX(instance_id) + FROM msdb.dbo.sysjobhistory WITH (NOLOCK) + GROUP BY job_id) AS l +ON sj.job_id = l.job_id +LEFT OUTER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) ON sj.category_id = sc.category_id -LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) -ON sj.job_id = js.job_id -LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) -ON js.schedule_id = s.schedule_id -ORDER BY sj.name OPTION (RECOMPILE); +LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) +ON h.job_id = l.job_id +AND h.instance_id = l.instance_id +ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); ------ -- Gives you some basic information about your SQL Server Agent jobs, who owns them and how they are configured diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2008R2.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2008R2.sql index c48450bccd..d201fa3ac2 100644 --- a/bin/diagnosticquery/SQLServerDiagnosticQueries_2008R2.sql +++ b/bin/diagnosticquery/SQLServerDiagnosticQueries_2008R2.sql @@ -1,7 +1,7 @@ -- SQL Server 2008 R2 Diagnostic Information Queries -- Glenn Berry --- Last Modified: January 3, 2023 +-- Last Modified: March 6, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -14,7 +14,7 @@ -- Please make sure you are using the correct version of these diagnostic queries for your version of SQL Server --****************************************************************************** ---* Copyright (C) 2023 Glenn Berry +--* Copyright (C) 2024 Glenn Berry --* All rights reserved. --* --* @@ -139,18 +139,24 @@ SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly]; -- Get SQL Server Agent jobs and Category information (Query 4) (SQL Server Agent Jobs) -SELECT sj.name AS [Job Name], sj.[description] AS [Job Description], SUSER_SNAME(sj.owner_sid) AS [Job Owner], +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, sc.name AS [CategoryName], -s.[enabled] AS [Sched Enabled], js.next_run_date, js.next_run_time +sj.notify_email_operator_id, sj.notify_level_email, h.run_status, +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] FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) -INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +LEFT OUTER JOIN + (SELECT job_id, instance_id = MAX(instance_id) + FROM msdb.dbo.sysjobhistory WITH (NOLOCK) + GROUP BY job_id) AS l +ON sj.job_id = l.job_id +LEFT OUTER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) ON sj.category_id = sc.category_id -LEFT OUTER JOIN msdb.dbo.sysjobschedules AS js WITH (NOLOCK) -ON sj.job_id = js.job_id -LEFT OUTER JOIN msdb.dbo.sysschedules AS s WITH (NOLOCK) -ON js.schedule_id = s.schedule_id -ORDER BY sj.name OPTION (RECOMPILE); +LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) +ON h.job_id = l.job_id +AND h.instance_id = l.instance_id +ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); ------ -- Gives you some basic information about your SQL Server Agent jobs, who owns them and how they are configured diff --git a/bin/diagnosticquery/SQLServerDiagnosticQueries_2012.sql b/bin/diagnosticquery/SQLServerDiagnosticQueries_2012.sql index 66c179f866..c3b538dd58 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: February 7, 2024 +-- Last Modified: March 6, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -370,14 +370,14 @@ sj.notify_email_operator_id, sj.notify_level_email, h.run_status, 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] FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) -INNER JOIN +LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) FROM msdb.dbo.sysjobhistory WITH (NOLOCK) GROUP BY job_id) AS l ON sj.job_id = l.job_id -INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) ON sj.category_id = sc.category_id -INNER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_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 3a32208f39..9a2ad8b781 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: February 7, 2024 +-- Last Modified: March 6, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -364,14 +364,14 @@ sj.notify_email_operator_id, sj.notify_level_email, h.run_status, 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] FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) -INNER JOIN +LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) FROM msdb.dbo.sysjobhistory WITH (NOLOCK) GROUP BY job_id) AS l ON sj.job_id = l.job_id -INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) ON sj.category_id = sc.category_id -INNER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_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 902fd6b8bf..de2807bfb5 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: February 7, 2024 +-- Last Modified: March 6, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -346,14 +346,14 @@ sj.notify_email_operator_id, sj.notify_level_email, h.run_status, 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] FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) -INNER JOIN +LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) FROM msdb.dbo.sysjobhistory WITH (NOLOCK) GROUP BY job_id) AS l ON sj.job_id = l.job_id -INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) ON sj.category_id = sc.category_id -INNER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_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 9a8fe73b6e..8170407e68 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: February 7, 2024 +-- Last Modified: March 6, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -328,14 +328,14 @@ sj.notify_email_operator_id, sj.notify_level_email, h.run_status, 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] FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) -INNER JOIN +LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) FROM msdb.dbo.sysjobhistory WITH (NOLOCK) GROUP BY job_id) AS l ON sj.job_id = l.job_id -INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) ON sj.category_id = sc.category_id -INNER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_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 8aced14b00..16f1113097 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: February 7, 2024 +-- Last Modified: March 6, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -349,14 +349,14 @@ sj.notify_email_operator_id, sj.notify_level_email, h.run_status, 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] FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) -INNER JOIN +LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) FROM msdb.dbo.sysjobhistory WITH (NOLOCK) GROUP BY job_id) AS l ON sj.job_id = l.job_id -INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) ON sj.category_id = sc.category_id -INNER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_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 e43e4aa812..41808c4c77 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: February 15, 2024 +-- Last Modified: March 6, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -331,14 +331,14 @@ sj.notify_email_operator_id, sj.notify_level_email, h.run_status, 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] FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) -INNER JOIN +LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) FROM msdb.dbo.sysjobhistory WITH (NOLOCK) GROUP BY job_id) AS l ON sj.job_id = l.job_id -INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) ON sj.category_id = sc.category_id -INNER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_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 b712a0bc66..47e907835a 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: February 7, 2024 +-- Last Modified: March 6, 2024 -- https://glennsqlperformance.com/ -- https://sqlserverperformance.wordpress.com/ -- YouTube: https://bit.ly/2PkoAM1 @@ -329,14 +329,14 @@ sj.notify_email_operator_id, sj.notify_level_email, h.run_status, 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] FROM msdb.dbo.sysjobs AS sj WITH (NOLOCK) -INNER JOIN +LEFT OUTER JOIN (SELECT job_id, instance_id = MAX(instance_id) FROM msdb.dbo.sysjobhistory WITH (NOLOCK) GROUP BY job_id) AS l ON sj.job_id = l.job_id -INNER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.syscategories AS sc WITH (NOLOCK) ON sj.category_id = sc.category_id -INNER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) +LEFT OUTER JOIN msdb.dbo.sysjobhistory AS h WITH (NOLOCK) ON h.job_id = l.job_id AND h.instance_id = l.instance_id ORDER BY CONVERT(INT, h.run_duration) DESC, [Last Start Date] DESC OPTION (RECOMPILE); diff --git a/dbatools.psd1 b/dbatools.psd1 index 11bee38423..a68fab99e8 100644 --- a/dbatools.psd1 +++ b/dbatools.psd1 @@ -11,7 +11,7 @@ RootModule = 'dbatools.psm1' # Version number of this module. - ModuleVersion = '2.1.8' + ModuleVersion = '2.1.9' # ID used to uniquely identify this module GUID = '9d139310-ce45-41ce-8e8b-d76335aa1789'