Thursday, March 22, 2012

SQL Server error log

To view the SQL Server error log
Start Microsoft SQL Server Management Studio, open Object Explorer, expand a server, expand Management, and then expand SQL Server Logs.

Right-click a log and click View SQL Server Log.

Or execute following statement:
SELECT SERVERPROPERTY('ErrorLogFileName')

You should get something like this:
G:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\ERRORLOG

1 comment:

  1. SSMS Object Explorer has GUI for error log. Navigate under Server -> Management -> SQL Server Logs.

    You can also use undocumented procedure xp_readerrorlog.

    EXEC xp_readerrorlog 0, 1, "string 1", "string 2"

    will search for "string 1" and "string 2" in current log file (first parameter, default 0) for SQL Engine (second parameter, default 1, to read SQL Agent log use 2). Call with no parameters to show current log file without search.

    ReplyDelete