October 19, 2015 at 1:16 pm
Comments posted to this topic are about the item Read SQL Error logs
October 26, 2015 at 3:58 am
Thank you very much for the info!!! :-):-):-)
November 16, 2015 at 12:39 pm
Thanks for this script.
November 18, 2015 at 7:21 am
Vasan,
Thanks for taking the time to share this script. Very useful. If I could make a suggestion, would it not be easier to use xp_enumerrorlogs to find the number of error logs instead of xp_dirtree?
Maybe something like this:
------------------------------------------------------------
-- Create temp table to hold results from xp_enumerrorlogs
------------------------------------------------------------
CREATE TABLE #ErrLogsDL
(
[Archive #] INT,
[Date] VARCHAR(255),
[Log File Size (Byte)] BIGINT
)
---------------------------------------------------------------
-- Populate the temp table with
-- the data returned by executing xp_enumerrorlogs
---------------------------------------------------------------
INSERT #ErrLogsDL([Archive #],[Date], [Log File Size (Byte)])
EXEC master.dbo.xp_enumerrorlogs
Thanks again.
Lee
December 23, 2015 at 2:42 am
Sir,
Thanks for your worthy suggestion. xp_enumerrorlogs works really good. Actually i am not aware on this thats what i prefered xp_dirtree option.
Now code has been updated as per your sugession.
Thanks a lot again !
Thanks,
Vasan
January 29, 2016 at 12:16 am
It is also easier to use a local table instead of a # or ## temp table
Example to get log entries for today sorted by date/time descending:
DECLARE @tmpTab TABLE (
LogDate DATETIME,
ProcessInfo VarChar(50),
[Text] VarChar(1000)
)
INSERT INTO @tmpTab EXEC sp_readerrorlog 0
SELECT * FROM @tmpTab
WHERE LogDate > DATEADD(d,0,DATEDIFF(d,0,GETDATE()))
ORDER BY LogDate DESC
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy