Errorlog

  • Hoi,

    Does anyone know how to read the sp_readerrorlog and only show the logs of the current date or an other specific date?

    kind regards,

    bryan

  • Insert the results of sp_errorlog into a table (temp table's fine) and then query that with a filter on the date.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Hoi Gail ,

    thanks for the response. ik did like you told and created a table where the content of the errorlog is in. now i am struggeling with a query to get only those lines with the logdate = current date. i have seen that you've got to do something with cast, but would appreciate for some help with this one.

    thanks in advance

    this is the simple table i created:

    create table #errorlog

    (logdate datetime,

    processinfo nchar(30),

    info nchar(2000))

  • WHERE logdate >= dateadd(dd, datediff(dd,0, getdate()),0) AND logdate < dateadd(dd, datediff(dd,0, getdate())+1,0)

    will get you today's records. Play with that and you should be able to get x days past easily

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • thanks a lot gail, you know working with oracle for the most time as a oracle dba and switching to sql server and back sometimes turns my mind up side down. but i am learning. thanks again.

    bryan

  • Hi,

    Since you have posted this in SQL 2005, you can use tip in below url to directly search between dates using xp_readerrorlog. Incase you are writing this code to send DBA Team mail whenever error occurs then you can specify this query directly in DBMail.

    http://www.sqlserverdba.co.cc/2009/03/spreaderrorlog-sql-2005-search-for.html

    Regards,
    Sakthi
    My Blog -> http://www.sqlserverdba.co.cc

  • I have an article on SQLteam that may help you out. http://www.sqlteam.com/article/using-xp_readerrorlog-in-sql-server-2005

  • sorry for the late reply but thanks Sakthi this also helped me

  • thanks for you reply dan. but is there a parameter for showing only for example the logs from for example today?

  • Yes look at the botttom of the article in the comments. you can use a data range so you can restrict/read log for whatever date range you woulod like.

  • Thanks Dan,

    you know what they say about IT guys (the first thing they do is not reading the manual(s)) , well maybe that's because i am from holland.

    kind regards

    bryan

Viewing 11 posts - 1 through 10 (of 10 total)

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