<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Xp_readerrorlog on SQL Server Scripts</title><link>https://www.sqlserver70.com/tags/xp_readerrorlog/</link><description>Recent content in Xp_readerrorlog on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Wed, 08 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/tags/xp_readerrorlog/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Server Error Log Search Script: xp_readerrorlog</title><link>https://www.sqlserver70.com/post/sql-server-error-log-search-script-xp-readerrorlog/</link><pubDate>Wed, 08 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-error-log-search-script-xp-readerrorlog/</guid><description>
&lt;h2 id="search-the-sql-server-error-log-with-xp_readerrorlog"&gt;Search the SQL Server Error Log with xp_readerrorlog&lt;/h2&gt;
&lt;p&gt;This script reads and filters the SQL Server error log using &lt;code&gt;xp_readerrorlog&lt;/code&gt; and &lt;code&gt;sys.sp_readerrorlog&lt;/code&gt;, supporting keyword search, date range filtering, and access to archived log files — all from T-SQL without touching the file system.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;The SQL Server error log records startup events, login failures, database state changes, backup completions, DBCC output, and any errors raised by the engine. When something goes wrong — a database goes suspect, a backup fails, or a login is repeatedly denied — the error log is the first place to look. SQL Server provides two built-in mechanisms for reading the log from T-SQL: the undocumented extended stored procedure &lt;code&gt;xp_readerrorlog&lt;/code&gt; and its documented wrapper &lt;code&gt;sys.sp_readerrorlog&lt;/code&gt;. Both support keyword filtering and date ranges, making them far more useful than opening the log file in SSMS's Log Viewer for scripted or automated diagnostic work. This script, adapted from the Read_errorlog.sql in the sqlserver-kit collection by Konstantin Taranov, demonstrates how to search one or more error log files efficiently from T-SQL.&lt;/p&gt;</description></item></channel></rss>