sp_LogHunter

sp_LogHunter


Ah, the error log. A veritable window into SQL Server’s soul. If you’re like me, and you want to pull your hair out every time you open it up to find something, go no further.

sp_LogHunter is here to save you from all your miseries. Well, except the ones that happened in high school.

I took the list of things that I normally look for in the error log, distilled them down into as compact a list as possible, and use built-in procedures to search for all of them, and return the results in order.

This will save you a ton of time, because you don’t have to do each search manually. Also, it returns all of the results in order, so you don’t have to go back and forth between searches.

You also don’t have to do the infinite doom scroll past successful logins, log backups, and other things that just get in the way of you finding problems.

Here are the current parameters for it:

@days_back int = -7, /*How many days back you want to look in the error logs*/
@custom_message nvarchar(4000) = NULL, /*If there's something you specifically want to search for*/
@custom_message_only bit = 0, /*If you only want to search for this specific thing*/
@first_log_only bit = 0, /*If you only want to search the first log file*/
@language_id int = 1033, /*If you want to use a language other than English*/
@help bit = 0, /*Get help*/
@debug bit = 0, /*Prints messages and selects from temp tables*/

As always, you can get more details using the @help parameter.

For a video walkthrough of the results and usage, watch this video:

Good luck out there!