Read All SQL Server Log Files

Read All SQL Server Log Files

You can use a script similar to the following to read through all SQL Server Log files:

CREATE PROCEDURE SearchLogFiles (@LogType INT = 1, Filter NVARCHAR(MAX) = '')ASBEGIN   DECLARE @LogsTable TABLE (LogIndex INT, LogDate DATETIME, LogSize INT)      DECLARE @LogRows TABLE (LogDate DATETIME,                               ProcessInfo NVARCHAR (4000),                               Test NVARCHAR (4000))    INSERT INTO @LogsTable   EXEC xp_enumerrorlogs @LogType    DECLARE @index INT = 0   WHILE @index 

Use it as follows:

Exec SearchLogFiles 1,'ERROR'


Share the Post: