Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 








Display SQL Server log errors

SQL Server Tips by Donald Burleson

This is one of the many SQL Server Windows scripts to display errors from the logs, from the book "High Performance SQL Server DBA".

 See code depot for full script

Sometimes error counts and analysis of log errors is not enough.  Perhaps an informational event that affected performance repetitively occurred in the logs for a particular day that was missed.  A good way of finding these cyclical, repetitive log events is by doing a daily volume analysis over the log to see if any day exploded with messages compared to the others.  The following procedure, up_bn_log_daily_volume , will break down message volume by day so one can easily see all log errors:  

IF OBJECT_ID('up_bn_log_daily_volumes') IS NOT NULL
    DROP PROCEDURE up_bn_log_daily_volumes
    IF OBJECT_ID('up_bn_log_daily_volumes') IS NOT NULL
        PRINT '<<< FAILED DROPPING PROCEDURE up_bn_log_daily_volumes >>>'
        PRINT '<<< DROPPED PROCEDURE up_bn_log_daily_volumes >>>'
CREATE PROCEDURE up_bn_log_daily_volumes
(@LogNumber smallint = 0, -- 0 is the current error log
 @ErrorsOnly bit = 0)
    DECLARE @DateLimit    datetime,
            @SQLStatement varchar(60)

    set nocount on
    set ARITHABORT off
    set ARITHIGNORE on
    set ANSI_WARNINGS off
    -- Error Log Information
    SELECT @SQLStatement = 'EXEC master..xp_readerrorlog'
    IF @LogNumber > 0
     SELECT @SQLStatement = @SQLStatement + ' ' + LTRIM(STR(@LogNumber))

    CREATE TABLE #errorlog (ErrorText varchar(255), ContinuationRow int)

    -- Remove entries that begin with a tab or are less then 35 characters in length - not date format.
        OR LEN(ErrorText) < 35
        OR isdate(SUBSTRING(ErrorText,1,10)) = 0

    -- Do only errors if requested
    IF @ErrorsOnly = 1
          FROM #errorlog
        WHERE NOT  (ErrorText LIKE '% error%' OR
                    ErrorText LIKE '%failed%' OR
                    ErrorText LIKE '%table corrupt%' OR
                    ErrorText LIKE '%level 16%' OR
                    ErrorText LIKE '%level 17%' OR
                    ErrorText LIKE '%level 21%' OR
                    ErrorText LIKE '%Severity: 16%' OR
                    ErrorText LIKE '%Severity: 17%' OR
                    ErrorText LIKE '%Severity: 21%') AND
                    ErrorText NOT LIKE '%DBCC CHECKALLOC%0 errors%' AND
                    ErrorText NOT LIKE '%DBCC CHECKTABLE
%0 errors%'
-- display daily volume analysis
        top 5 day = substring(ErrorText,1,10),
        message_count = sum(isdate(substring(ErrorText,1,10)))

See code depot for full script

IF OBJECT_ID('up_bn_log_daily_volumes') IS NOT NULL
    PRINT '<<< CREATED PROCEDURE up_bn_log_daily_volumes >>>'
    PRINT '<<< FAILED CREATING PROCEDURE up_bn_log_daily_volumes >>>'
GRANT EXECUTE ON up_bn_log_daily_volumes TO public

This is one of the many SQL Server scripts to display error log statistics from the book "High Performance SQL Server DBA".



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.