Competition: What’s your favorite Redgate tool? Enter now.

Tracking specific error numbers

I'd like to use SQL Monitor to track and alert me when specific SQL errors are generated. At the moment, I'm tracking 833 errors on one of our servers and am using SQL Agent Alerts to email.

Does anyone know a way of doing this on SQL Monitor?

Regards

Andrew
Tagged:

Best Answer

  • crimdoncrimdon Posts: 54 Bronze 3
    edited August 8, 2019 3:43PM Accepted Answer
    Hi there,

    Thanks for your reply. I've decided to do it with a custom metric using this scrip:

    DROP TABLE IF EXISTS #errorLog;

    CREATE TABLE #errorLog
    (
        LogDate DATETIME,
        ProcessInfo VARCHAR(64),
        [Text] VARCHAR(MAX)
    );
    DECLARE @starttime DATETIME = DATEADD(MINUTE, -5, GETDATE()), @now DATETIME = GETDATE()

    INSERT INTO #errorLog
    EXEC xp_readerrorlog 0,1,NULL, NULL, @starttime, @now
    SELECT COUNT(*)
    FROM #errorLog a
    WHERE EXISTS
    (
        SELECT *
        FROM #errorLog b
        WHERE [Text] LIKE '%I/O requests taking longer than 15 seconds%'
              AND a.LogDate = b.LogDate
              AND a.ProcessInfo = b.ProcessInfo
    );

    DROP TABLE IF EXISTS #errorLog;

    Regards


    Andrew

Answers

Sign In or Register to comment.