- Blog - http://blog.bennett-scharf.com -

Simple SQL Server Log Filter / Review Script

Posted By Bennett On 28. March 2008 @ 19:23 In T-SQL | No Comments

Here’s a very basic log filtering /review script that you can run on a daily basis to review your SQL Server logs. It shows the last two days of log entries filtering out logon and backup entries.

– daily log review script
SET nocount ON
CREATE TABLE
#Errors
(
LogDate DateTime,
ProcessInfo NVARCHAR(40),
ErrorText NVARCHAR(2048)
)
INSERT INTO #Errors
EXEC master..sp_readerrorlog -1

SELECT * FROM #Errors
WHERE DATEDIFF(DAY, LogDate, GETDATE())<2
AND ProcessInfo <> ‘Logon’
AND ProcessInfo <> ‘Backup’
DROP TABLE #Errors

I’m currently cooking up some VBScript to filter and e-mail log entries on a daily basis. I’ll publish that soon.


Article printed from Blog: http://blog.bennett-scharf.com

URL to article: http://blog.bennett-scharf.com/2008/03/28/simple-sql-server-log-filter-review-script/

Click here to print.