SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Want to read error logs on paticlar date


Want to read error logs on paticlar date

Author
Message
Simha24
Simha24
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1618 Visits: 319
Hi

I wants to read error logs on this month 16th and 17th dates.
Due to huge size of the error logs, How can i read my error logs as simple as possible.


it is possible to read error logs on particluar date range with EXEC sys.xp_readerrorlog 0,1

How can pass date range in above sp
anthony.green
anthony.green
SSC Guru
SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)

Group: General Forum Members
Points: 104540 Visits: 8698
load the log into a temp table then do a query against the date column

create table @errorlog (date, source, message)

insert into @errorlog exec sp_readerrorlog

select * from @errorlog where date >= '' and date <= ''

there is no way to pass in a paramater to the sp_readerrorlog that I know of, other than using the log viewer but that will read the log then filter it down which is the same as the above.



How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Simha24
Simha24
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1618 Visits: 319
Thanks...i will try
sestell1
sestell1
SSCrazy Eights
SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)SSCrazy Eights (9.5K reputation)

Group: General Forum Members
Points: 9508 Visits: 4511
I believe the 5th and 6th parameters to xp_ReadErrorLog are start and stop datetimes respectively, so you should be able to do something like:

EXEC xp_ReadErrorLog 0, 1, Null, Null, '2012-05-16 00:00:00', '2012-05-17 23:59:59'



Here is my understanding of the parameters:

Parameter 1 = log version (0 = current)
Parameter 2 = log type (1 = error, 2 = agent)
Parameter 3 = Search string
Parameter 4 = Search string
Parameter 5 and 6 I believe are start/end datetime restrictions

Hope this helps.
vikingDBA
vikingDBA
SSCertifiable
SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)

Group: General Forum Members
Points: 5030 Visits: 929
Here is a quick, easy way that I do it:


/* =================================================================================================================== */
/* Load SQL Error Logs to a temp table for research


Whole script at:
http://www.sqlservercentral.com/scripts/Error+Logging/70611/
*/


CREATE TABLE #SQLErrorLog
(
LogDate DATETIME,
ProcessInfo VARCHAR(20),
Text VARCHAR(500)
)
GO

INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 0
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 1
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 2
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 3
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 4
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 5
go

SELECT * FROM #SQLErrorLog
WHERE Text LIKE '%fail%' OR Text LIKE '%error%'
ORDER BY LogDate DESC

SELECT * FROM #SQLErrorLog
WHERE LogDate >= CONVERT(datetime,'05/04/2012') AND LogDate < CONVERT(datetime,'05/16/2012')
ORDER BY LogDate DESC

DROP TABLE #SQLErrorLog
Minnesota - Viking
Minnesota - Viking
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2991 Visits: 564
This worked like a charm, just make sure that you define the text column as large as needed.
Thanks for the post and thanks to the original post's author too.


-- Create a temporary table
CREATE TABLE #SQLErrorLog
(
LogDate DATETIME,
ProcessInfo VARCHAR(200),
Text VARCHAR(1900)
)
GO



vikingDBA (5/11/2012)
Here is a quick, easy way that I do it:


/* =================================================================================================================== */
/* Load SQL Error Logs to a temp table for research


Whole script at:
http://www.sqlservercentral.com/scripts/Error+Logging/70611/
*/


CREATE TABLE #SQLErrorLog
(
LogDate DATETIME,
ProcessInfo VARCHAR(20),
Text VARCHAR(500)
)
GO

INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 0
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 1
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 2
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 3
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 4
go
INSERT INTO #SQLErrorLog
EXEC xp_readerrorlog 5
go

SELECT * FROM #SQLErrorLog
WHERE Text LIKE '%fail%' OR Text LIKE '%error%'
ORDER BY LogDate DESC

SELECT * FROM #SQLErrorLog
WHERE LogDate >= CONVERT(datetime,'05/04/2012') AND LogDate < CONVERT(datetime,'05/16/2012')
ORDER BY LogDate DESC

DROP TABLE #SQLErrorLog




Today is the tomorrow you worried about yesterday:-)

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search