• Have been playing around with intentionally corrupting database files and database backup files to see how the various commands that have been discussed so far will behave. This is on a 1GB database.

    Changing the first byte or a byte some where in the middle causes DBCC CHECKDB and BACKUP WITH CHECKSUM to fail.

    Changing the last byte or a byte 'near the end' generates no errors.

    This is true also of RESTORE VERIFYONLY WITH CHECKSUM. For this to generate an error I had to change a byte as far as 20% from the end. Interesting.

    Now I'm trying to catch errors using this simple code.

    declare @err int

    begin try

    --dbcc checkdb('mydatabase')

    --restore verifyonly from disk='mydatabase.bak' with checksum

    end try

    begin catch

    set @err=@@error

    if @err<>0 select @err

    end catch

    RESTORE VERIFYONLY correctly shows error 3013.

    DBCC CHECKDB does not generate any red error messages. But if you run it all by itself the output shows red error messages. Why is this?