1- -- Compile Date: 06/19/2024 14:59:27 UTC
1+ -- Compile Date: 06/19/2024 15:27:16 UTC
22SET ANSI_NULLS ON;
33SET ANSI_PADDING ON;
44SET ANSI_WARNINGS ON;
6666 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
6767
6868 SELECT
69- @version = '1.5 ',
70- @version_date = '20240401 ';
69+ @version = '1.7 ',
70+ @version_date = '20240701 ';
7171
7272 IF @help = 1
7373 BEGIN
@@ -2960,8 +2960,8 @@ SET XACT_ABORT ON;
29602960SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
29612961
29622962SELECT
2963- @version = '5.5 ',
2964- @version_date = '20240401 ';
2963+ @version = '5.7 ',
2964+ @version_date = '20240701 ';
29652965
29662966IF @help = 1
29672967BEGIN
@@ -7687,8 +7687,8 @@ SET XACT_ABORT ON;
76877687SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
76887688
76897689SELECT
7690- @version = '3.5 ',
7691- @version_date = '20240401 ';
7690+ @version = '3.7 ',
7691+ @version_date = '20240701 ';
76927692
76937693IF @help = 1
76947694BEGIN
@@ -10510,20 +10510,20 @@ SET STATISTICS TIME, IO OFF;
1051010510GO
1051110511
1051210512/*
10513- ██╗ ██████╗ ██████╗
10514- ██║ ██╔═══██╗██╔════╝
10515- ██║ ██║ ██║██║ ███╗
10516- ██║ ██║ ██║██║ ██║
10517- ███████╗╚██████╔╝╚██████╔╝
10518- ╚══════╝ ╚═════╝ ╚═════╝
10519-
10513+ ██╗ ██████╗ ██████╗
10514+ ██║ ██╔═══██╗██╔════╝
10515+ ██║ ██║ ██║██║ ███╗
10516+ ██║ ██║ ██║██║ ██║
10517+ ███████╗╚██████╔╝╚██████╔╝
10518+ ╚══════╝ ╚═════╝ ╚═════╝
10519+
1052010520██╗ ██╗██╗ ██╗███╗ ██╗████████╗███████╗██████╗
1052110521██║ ██║██║ ██║████╗ ██║╚══██╔══╝██╔════╝██╔══██╗
1052210522███████║██║ ██║██╔██╗ ██║ ██║ █████╗ ██████╔╝
1052310523██╔══██║██║ ██║██║╚██╗██║ ██║ ██╔══╝ ██╔══██╗
1052410524██║ ██║╚██████╔╝██║ ╚████║ ██║ ███████╗██║ ██║
1052510525╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
10526-
10526+
1052710527Copyright 2024 Darling Data, LLC
1052810528https://www.erikdarling.com/
1052910529
@@ -10542,10 +10542,10 @@ EXEC sp_LogHunter;
1054210542
1054310543*/
1054410544
10545- IF OBJECT_ID('dbo.sp_LogHunter') IS NULL
10546- BEGIN
10547- EXEC ('CREATE PROCEDURE dbo.sp_LogHunter AS RETURN 138;');
10548- END;
10545+ IF OBJECT_ID('dbo.sp_LogHunter') IS NULL
10546+ BEGIN
10547+ EXEC ('CREATE PROCEDURE dbo.sp_LogHunter AS RETURN 138;');
10548+ END;
1054910549GO
1055010550
1055110551ALTER PROCEDURE
@@ -10565,15 +10565,15 @@ ALTER PROCEDURE
1056510565)
1056610566WITH RECOMPILE
1056710567AS
10568- SET STATISTICS XML OFF;
10568+ SET STATISTICS XML OFF;
1056910569SET NOCOUNT ON;
10570- SET XACT_ABORT ON;
10570+ SET XACT_ABORT ON;
1057110571SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
1057210572
1057310573BEGIN
1057410574 SELECT
10575- @version = '1.5 ',
10576- @version_date = '20240401 ';
10575+ @version = '1.7 ',
10576+ @version_date = '20240701 ';
1057710577
1057810578 IF @help = 1
1057910579 BEGIN
@@ -10583,7 +10583,7 @@ BEGIN
1058310583 SELECT 'you can use me to look through your error logs for bad stuff' UNION ALL
1058410584 SELECT 'all scripts and documentation are available here: https://github.com/erikdarlingdata/DarlingData/tree/main/sp_LogHunter' UNION ALL
1058510585 SELECT 'from your loving sql server consultant, erik darling: https://erikdarling.com';
10586-
10586+
1058710587 SELECT
1058810588 parameter_name =
1058910589 ap.name,
@@ -10638,38 +10638,38 @@ BEGIN
1063810638 AND ap.user_type_id = t.user_type_id
1063910639 WHERE o.name = N'sp_LogHunter'
1064010640 OPTION(RECOMPILE);
10641-
10641+
1064210642 SELECT
1064310643 mit_license_yo = 'i am MIT licensed, so like, do whatever'
10644-
10644+
1064510645 UNION ALL
10646-
10646+
1064710647 SELECT
1064810648 mit_license_yo = 'see printed messages for full license';
10649-
10649+
1065010650 RAISERROR('
1065110651 MIT License
10652-
10652+
1065310653 Copyright 2024 Darling Data, LLC
10654-
10654+
1065510655 https://www.erikdarling.com/
10656-
10656+
1065710657 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
1065810658 to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute,
1065910659 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
1066010660 following conditions:
10661-
10661+
1066210662 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10663-
10663+
1066410664 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1066510665 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
1066610666 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1066710667 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1066810668 ', 0, 1) WITH NOWAIT;
10669-
10669+
1067010670 RETURN;
1067110671 END;
10672-
10672+
1067310673 /*Check if we have sa permissisions*/
1067410674 IF
1067510675 (
@@ -10715,7 +10715,7 @@ BEGIN
1071510715 RAISERROR(N'%i is not not a valid language_id in sys.messages.', 11, 1, @language_id) WITH NOWAIT;
1071610716 RETURN;
1071710717 END;
10718-
10718+
1071910719 /*Fix days back a little bit*/
1072010720 IF @days_back = 0
1072110721 BEGIN
@@ -10728,7 +10728,7 @@ BEGIN
1072810728 SELECT
1072910729 @days_back *= -1;
1073010730 END;
10731-
10731+
1073210732 IF @start_date IS NOT NULL
1073310733 AND @end_date IS NOT NULL
1073410734 AND @days_back IS NOT NULL
@@ -10777,7 +10777,7 @@ BEGIN
1077710777 @t_searches int = 0 /*total number of searches to run*/,
1077810778 @l_count int = 1 /*loop count*/,
1077910779 @stopper bit = 0 /*stop loop execution safety*/;
10780-
10780+
1078110781 /*temp tables for holding temporary things*/
1078210782 CREATE TABLE
1078310783 #error_log
@@ -10786,7 +10786,7 @@ BEGIN
1078610786 process_info nvarchar(100),
1078710787 text nvarchar(4000)
1078810788 );
10789-
10789+
1079010790 CREATE TABLE
1079110791 #enum
1079210792 (
@@ -10857,7 +10857,7 @@ BEGIN
1085710857 AND e.archive > 0
1085810858 OPTION(RECOMPILE);
1085910859 END;
10860-
10860+
1086110861 /*filter out log files we won't use, if @start_date and @end_date are set*/
1086210862 IF @start_date IS NOT NULL
1086310863 AND @end_date IS NOT NULL
@@ -10966,7 +10966,7 @@ BEGIN
1096610966 N'"' + CONVERT(nvarchar(30), @end_date) + N'"'
1096710967 ) AS c
1096810968 WHERE @custom_message_only = 0
10969- OPTION(RECOMPILE);
10969+ OPTION(RECOMPILE);
1097010970
1097110971 /*deal with a custom search string here*/
1097210972 INSERT
@@ -10999,7 +10999,7 @@ BEGIN
1099910999 BEGIN
1100011000 SELECT table_name = '#search', s.* FROM #search AS s;
1100111001 END;
11002-
11002+
1100311003 /*Set the min and max logs we're getting for the loop*/
1100411004 SELECT
1100511005 @l_log = MIN(e.archive),
@@ -11016,7 +11016,7 @@ BEGIN
1101611016 END;
1101711017
1101811018 IF @debug = 1 BEGIN RAISERROR('Declaring cursor', 0, 1) WITH NOWAIT; END;
11019-
11019+
1102011020 /*start the loops*/
1102111021 WHILE @l_log <= @h_log
1102211022 BEGIN
@@ -11031,17 +11031,17 @@ BEGIN
1103111031 SELECT
1103211032 command
1103311033 FROM #search;
11034-
11034+
1103511035 IF @debug = 1 BEGIN RAISERROR('Opening cursor', 0, 1) WITH NOWAIT; END;
11036-
11036+
1103711037 OPEN c;
11038-
11038+
1103911039 FETCH FIRST
1104011040 FROM c
1104111041 INTO @c;
1104211042
1104311043 IF @debug = 1 BEGIN RAISERROR('Entering WHILE loop', 0, 1) WITH NOWAIT; END;
11044- WHILE @@FETCH_STATUS = 0 AND @stopper = 0
11044+ WHILE @@FETCH_STATUS = 0 AND @stopper = 0
1104511045 BEGIN
1104611046 IF @debug = 1 BEGIN RAISERROR('Entering cursor', 0, 1) WITH NOWAIT; END;
1104711047 /*Replace the canary value with the log number we're working in*/
@@ -11058,9 +11058,9 @@ BEGIN
1105811058 BEGIN
1105911059 RAISERROR('log %i of %i', 0, 1, @l_log, @h_log) WITH NOWAIT;
1106011060 RAISERROR('search %i of %i', 0, 1, @l_count, @t_searches) WITH NOWAIT;
11061- RAISERROR('@c: %s', 0, 1, @c) WITH NOWAIT;
11061+ RAISERROR('@c: %s', 0, 1, @c) WITH NOWAIT;
1106211062 END;
11063-
11063+
1106411064 IF @debug = 1 BEGIN RAISERROR('Inserting to error log', 0, 1) WITH NOWAIT; END;
1106511065 BEGIN
1106611066 BEGIN TRY
@@ -11085,10 +11085,10 @@ BEGIN
1108511085 VALUES
1108611086 (
1108711087 @c
11088- );
11088+ );
1108911089 END CATCH;
1109011090 END;
11091-
11091+
1109211092 IF @debug = 1 BEGIN RAISERROR('Fetching next', 0, 1) WITH NOWAIT; END;
1109311093 /*Get the next search command*/
1109411094 FETCH NEXT
@@ -11100,7 +11100,7 @@ BEGIN
1110011100 @l_count += 1;
1110111101
1110211102 END;
11103-
11103+
1110411104 IF @debug = 1 BEGIN RAISERROR('Getting next log', 0, 1) WITH NOWAIT; END;
1110511105 /*Increment the log numbers*/
1110611106 SELECT
@@ -11112,18 +11112,18 @@ BEGIN
1111211112
1111311113 IF @debug = 1
1111411114 BEGIN
11115- RAISERROR('log %i of %i', 0, 1, @l_log, @h_log) WITH NOWAIT;
11115+ RAISERROR('log %i of %i', 0, 1, @l_log, @h_log) WITH NOWAIT;
1111611116 END;
1111711117
1111811118 /*Stop the loop if this is NULL*/
1111911119 IF @l_log IS NULL
1112011120 BEGIN
11121- IF @debug = 1 BEGIN RAISERROR('Breaking', 0, 1) WITH NOWAIT; END;
11121+ IF @debug = 1 BEGIN RAISERROR('Breaking', 0, 1) WITH NOWAIT; END;
1112211122 SET @stopper = 1;
1112311123 BREAK;
11124- END;
11124+ END;
1112511125 IF @debug = 1 BEGIN RAISERROR('Ended WHILE loop', 0, 1) WITH NOWAIT; END;
11126-
11126+
1112711127 /*Close out the cursor*/
1112811128 CLOSE c;
1112911129 DEALLOCATE c;
@@ -11179,7 +11179,7 @@ BEGIN
1117911179 1/0
1118011180 FROM #errors AS e
1118111181 )
11182- BEGIN
11182+ BEGIN
1118311183 SELECT
1118411184 table_name =
1118511185 '#errors',
@@ -11264,8 +11264,8 @@ SET XACT_ABORT ON;
1126411264SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
1126511265
1126611266SELECT
11267- @version = '4.5 ',
11268- @version_date = '20240401 ';
11267+ @version = '4.7 ',
11268+ @version_date = '20240701 ';
1126911269
1127011270
1127111271IF @help = 1
@@ -14322,8 +14322,8 @@ END;
1432214322These are for your outputs.
1432314323*/
1432414324SELECT
14325- @version = '4.5 ',
14326- @version_date = '20240401 ';
14325+ @version = '4.7 ',
14326+ @version_date = '20240701 ';
1432714327
1432814328/*
1432914329Helpful section! For help.
0 commit comments