March 3, 2009 at 4:50 am
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
March 3, 2009 at 4:53 am
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
March 3, 2009 at 6:47 am
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))
March 3, 2009 at 7:17 am
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
March 3, 2009 at 7:42 am
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
March 4, 2009 at 12:43 am
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
March 4, 2009 at 1:08 pm
I have an article on SQLteam that may help you out. http://www.sqlteam.com/article/using-xp_readerrorlog-in-sql-server-2005
March 7, 2009 at 2:12 pm
sorry for the late reply but thanks Sakthi this also helped me
March 7, 2009 at 2:13 pm
thanks for you reply dan. but is there a parameter for showing only for example the logs from for example today?
March 8, 2009 at 4:23 am
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.
March 8, 2009 at 6:21 am
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