You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sp_LogHunter/sp_LogHunter.sql
+32-1Lines changed: 32 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -241,6 +241,21 @@ BEGIN
241
241
@custom_message_only =0;
242
242
END;
243
243
244
+
/*
245
+
@custom_message_only = 1 means "skip the canned search strings and
246
+
look only for the user-supplied @custom_message". Without a message
247
+
to search for, every insert branch below would skip (the custom
248
+
insert is gated on @custom_message LIKE N'_%', which is NULL/false
249
+
for NULL or empty input), leaving #search empty and the whole
250
+
outer loop a no-op. Reject the combination up front.
251
+
*/
252
+
IF @custom_message_only =1
253
+
AND (@custom_message ISNULLORLEN(@custom_message) =0)
254
+
BEGIN
255
+
RAISERROR(N'@custom_message_only = 1 requires a non-empty @custom_message. Provide a search string or set @custom_message_only = 0.', 11, 1) WITHNOWAIT;
256
+
RETURN;
257
+
END;
258
+
244
259
/*Fix @end_date*/
245
260
IF @start_date ISNOTNULL
246
261
AND @end_date ISNULL
@@ -412,8 +427,24 @@ BEGIN
412
427
CROSSJOIN
413
428
(
414
429
SELECT
430
+
/*
431
+
Canary floor is normally "at least 90 days back" so these
432
+
server-identity strings are found regardless of how recent
433
+
the caller is interested in. When the caller supplied
434
+
@start_date/@end_date, @days_back is NULL at this point —
435
+
the previous CASE collapsed to NULL, produced a NULL
436
+
days_back literal, and xp_readerrorlog received NULL as a
437
+
date argument and errored. Fall back to @start_date in
438
+
date-range mode so the canary has a concrete floor.
0 commit comments