This article is half-done without your Comment! *** Please share your thoughts via Comment ***
This is one of the important articles for all Database Administrators who are playing with the SQL Server Error Logs.
Generally, we are checking an error log file for monitoring and troubleshooting errors in SQL Server.
But the problem is when we are finding the errors for a particular process, it is difficult to filter a specific error.
In this post, I am providing the script for manipulating all error logs using T-SQL.
Script to list out all error log files:
You can find the list of error log files with a file size and Archive File number.
1 |
xp_enumerrorlogs |
Script to SELECT error log of a particular file by giving a file number:
File number ‘0’ is for current file.
1 |
EXEC [master].[dbo].[xp_readerrorlog] 0 |
CREATE TEMP table and store all error logs for better manipulation:
1 2 3 4 5 6 7 8 9 10 11 12 |
CREATE TABLE #TempErrorLogs ( [LogDate] DATETIME ,[ProcessInfo] VARCHAR(50) ,[Text] VARCHAR(MAX) ) GO INSERT INTO #TempErrorLogs ([LogDate], [ProcessInfo], [Text]) EXEC [master].[dbo].[xp_readerrorlog] 0 GO |