• Michael Meierruth (9/28/2012)


    rmechaber (9/28/2012)


    Did you see my post on page 3 of the comments?

    Rich

    Yes, it's 200 lines of code and comments (I like those!)

    But I'm comparing 1 line of my code (a single DBCC CHECKDATABSE) with 8 lines of my trivial code trying to trap an error.

    Why are they getting different results in the Messages window?

    Where am I going wrong?

    Sorry Michael, I didn't read your post closely enough to realize that you were getting different results back when checking the same database. I have no idea, and I'll look forward to Paul Randal's reply.

    I just tried running your code block against a Broken database I downloaded from Paul's website and compared the output from a direct run [DBCC CHECKDB('broken')] with your code block (also checking DB 'broken'). I saved the output from both runs to text files and ran them through a text comparison utility; the direct run had the following lines in the output that were missing from the TRY..CATCH attempt:

    Msg 8928, Level 16, State 1, Line 1

    Object ID 2073058421, index ID 0, partition ID 72057594038321152, alloc unit ID 72057594042318848 (type In-row data): Page (1:143) could not be processed. See other errors for details.

    Msg 8939, Level 16, State 98, Line 1

    Table error: Object ID 2073058421, index ID 0, partition ID 72057594038321152, alloc unit ID 72057594042318848 (type In-row data), page (1:143). Test (IS_OFF (BUF_IOERR, pBUF->bstat)) failed. Values are 29493257 and -4.

    Rich

    P.S. Add'l: I am wondering if this is an artifact of the TRY..CATCH block itself. I don't use it enough myself to know if this is related, but you might want to look here and here.