Monday, April 21, 2008

Reading SQL Server log files using T-SQL or VBScript

Reading the SQL Server log files using T-SQL

EXEC sys.xp_readerrorlog

SQL Server 2005 offers an undocumented system stored procedure sp_readerrorlog.
This SP allows you to read the contents of the SQL Server error log files directly from a query window and also allows you to search for certain keywords when reading the error file.
This is a sample of the stored procedure for SQL Server 2005. You will see that when this gets called it calls an extended stored procedure xp_readerrorlog.

see also:
Simple way to find errors in SQL Server error log - a method of searching the error log using VBScript (Scripting.FileSystemObject).

No comments: