Last week at SQL Connections someone said that CHECKDB’s output is ‘useless’. Given that I wrote CHECKDB for SQL Server 2005 I was only mildly offended :-) But there’s a lot of truth in that statement – the error messages from CHECKDB do tell you exactly what’s corrupt in the database but they’re not exactly easy to read and understand unless you’re intimately familiar with the on-disk structures used to store a SQL Server database. It’s pretty easy to understand the output if there’s only one or two error messages, but once you get past 10 or so it becomes extremely difficult to figure out what the actual problem is for normal people (i.e. not CHECKDB geeks like me, Ryan or a handful of senior people in Product Support) So, how are you supposed to figure out what’s wrong? In this post I want to run through a few tips and tricks you can use. While I was at Microsoft I wrote two 200-page+ documents detailing all the CHECKDB error messages for SQL Server 2000 and 2005 – the team says they should all be translated into Books Online entries by next summer – a bunch of them are there already. In the meantime, I hope the hints above will take a little of the mystery out of CHECKDB’s output.
Black Friday Super Sale!
It’s the time of year again where companies do crazy sales on the day after Thanksgiving in the US, and we’re doing the same! All
12 thoughts on “CHECKDB From Every Angle: Tips and tricks for interpreting CHECKDB output”
Paul,
If you dump the output of dbcc checkdb REPAIR_REBUILD to a table using the WITH TABLERESULTS option, how to you analyze the data (via query) to verify all the corruption was able to be repaired? I need to do this as part of an automated job. Any help would be greatly appreciated.
You need to look for the found count = fixed count. And then you need to run repair again to make sure it doesn’t find anything else (from a repair opening up a bit more of the database to being checked).
Did that 200 page document ever get translated to Books Online, if so, where can we find it?
Nope. At some point I might get around to fixing it up and making it available.
As an accidental DBA, your blog is an essential lifeline for me (along with the SQL Internals and the handouts from the immersion days)
Currently DBCC docs are here: https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-checkdb-transact-sql
Sadly the online docs are missing out on your great insights (i.e. explaining error messages and down-to-earth solutions to real problems)
It is great to see that all your work made it through to the community, I truly love it :)
Ciao Paul, see you in Dublin
Thanks Matteo!
Where can I find details about the information returned by CHECKDB, especially when using WITH TABLERESULTS?
I’m designing a job to run CHECKDB on all of our servers, as nothing has ever been run on them in who knows how many years – I’m the new DBA, if you hadn’t guessed – and I want to save the results to a permanent table for later analysis.
There isn’t a good, published description of all the messages. If you Google for CHECKDB TABLERESULTS you’ll find people who have published scripts to capture the output that you want.
Yes, I found loads of those, though most create a table with RepairLevel being an INT. I’m running SQL Server 2016 at work, and 2017 on my laptop for testing. On 2017, I find RepairLevel is a VARCHAR not an INT. Do you know if that is the same on 2016?
So far haven’t been able to find anything that provides a description of what each column means. Some are obvious, but others aren’t.
It’s undocumented and can change from version to version, so there’s no official description. They’re all to do with error messages, and you can work them out for each error message as you also get the entire message as part of the result set.
To be honest, most of the time you just need to know was there any output, then you’ve got problems. Always use WITH NO_INFOMSGS too.
BTW Thanks for your awesome insight into CHECKDB, I’ve read many of your blogs and am also using your example corrupt DBs for testing.
NP – helps that I wrote it :-)