How to view sql server error logs?

  • We have SQL Server 2000 (SP4) running on Windows 2003 Server. In SQL EM, when I click on the current error log (8 mb in size) the EM hangs. Is this file too large for EM? May I view the current log in notepad by opening the log file on the operating system? Are there any other ways to view the log files?

    Thanks in advance, Kevin

    BTW, I just realized I should have posted this under SQL Server 2000. Sorry.

  • You might be able to get data out of them with xp_readerrorlogs. It's an undocumented extended stored procedure that's included with SQL Server. Search for it online, you'll find what others have done with it. That's as close as it gets to documentation.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • kevinsql7 (12/1/2009)


    We have SQL Server 2000 (SP4) running on Windows 2003 Server. In SQL EM, when I click on the current error log (8 mb in size) the EM hangs. Is this file too large for EM? May I view the current log in notepad by opening the log file on the operating system? Are there any other ways to view the log files?

    Thanks in advance, Kevin

    BTW, I just realized I should have posted this under SQL Server 2000. Sorry.

    You can view the error log file in any text editor (yes notepad). They must be in \MSSQL\LOG directory


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

  • Use this Script.

    DECLARE @HOURS INT

    SET @HOURS = 24

    CREATE Table #ErrorLog (ErrorLog varchar(1000),ContinuationRow Int)

    Insert into #ErrorLog (ErrorLog,ContinuationRow)

    EXEC sp_readerrorlog

    Delete from #ErrorLog

    where (LEFT(LTRIM(ErrorLog),4) NOT LIKE Datepart(YYYY,getdate()) and ContinuationRow = 0)

    OR ContinuationRow = 1

    Delete from #ErrorLog WHERE LEN(ErrorLog) < 25

    DELETE FROM #ErrorLog

    WHERE (CAST(LEFT(LTRIM(ErrorLog),23) as Datetime) < CAST(Dateadd(hh,-@HOURS,getdate()) AS VARCHAR(23)))

    SELECT * FROM #ErrorLog

    Drop Table #ErrorLog

    It will display the error log for the past 24 hours

    Works in SQL 2000 Only.. If you need script for 2005 let me know.


    Bru Medishetty

    Blog -- LearnSQLWithBru

    Join on Facebook Page Facebook.comLearnSQLWithBru

    Twitter -- BruMedishetty

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply