{"id":1070,"date":"2008-03-13T20:32:17","date_gmt":"2008-03-13T20:32:17","guid":{"rendered":"\/blogs\/paul\/post\/CHECKDB-From-Every-Angle-When-did-DBCC-CHECKDB-last-run-successfully.aspx"},"modified":"2021-09-18T13:38:27","modified_gmt":"2021-09-18T20:38:27","slug":"checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/","title":{"rendered":"CHECKDB From Every Angle: When did DBCC CHECKDB last run successfully?"},"content":{"rendered":"<p>[Edit: From 2016 SP2 onward, you can use SELECT DATABASEPROPERTYEX (\u2018dbname\u2019 , \u2018LastGoodCheckDbTime\u2019 ); instead]<\/p>\n<p>This came up several times during the week so I thought it was about time to blog about it. One of the new features we put into SQL Server 2005 was storing the last time that <em>DBCC CHECKDB<\/em> completed successfully (called the <em>last-known good time<\/em>). It&#8217;s the time that the DBCC CHECKDB *started*, not completed.<\/p>\n<p>What does <em>successfully<\/em> mean? This is the catch &#8211; if <em>DBCC CHECKDB<\/em> runs to completion then it considers that a successful run &#8211; EVEN if it found some corruptions. However, the last-known good time is\u00a0ONLY updated if there were NO corruptions found. Slightly confusing I know.<\/p>\n<p>Cool &#8211; but how can you see it? Well, the only time it&#8217;s ever reported is when the database starts up. Not too useful if the database has been running for months. So how to see it??? The trick is to use <em>DBCC PAGE<\/em>. The\u00a0last-known good time\u00a0is stored in the boot page of the database &#8211; page 9. The following code will dump page 9 for you:<\/p>\n<blockquote dir=\"ltr\" style=\"margin-right: 0px;\"><p>&#8212; you need this to get any DBCC PAGE output<br \/>\n<span style=\"color: #0000ff;\"><span style=\"font-family: 'Courier New';\">DBCC<\/span><\/span><span style=\"font-family: 'Courier New';\"><span style=\"color: #000000;\"> TRACEON <\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #000000;\">3604<\/span><span style=\"color: #808080;\">);<\/span><\/span><span style=\"color: #000000; font-family: 'Courier New';\"><br \/>\n<\/span><span style=\"font-family: 'Courier New';\">GO<\/span><\/p>\n<p>&#8212; page 9 is the boot page<br \/>\n<span style=\"color: #0000ff;\"><span style=\"font-family: 'Courier New';\">DBCC<\/span><\/span><span style=\"font-family: 'Courier New';\"><span style=\"color: #000000;\"> PAGE <\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #000000;\">dbname<\/span><span style=\"color: #808080;\">,<\/span><span style=\"color: #000000;\"> 1<\/span><span style=\"color: #808080;\">,<\/span><span style=\"color: #000000;\"> 9<\/span><span style=\"color: #808080;\">,<\/span><span style=\"color: #000000;\"> 3<\/span><span style=\"color: #808080;\">);<br \/>\n<\/span><\/span><span style=\"font-family: 'Courier New'; font-size: small;\">GO<\/span><\/p><\/blockquote>\n<p>You need to look for the <em>dbi_dbccLastKnownGood<\/em> field. That was the last time that <em>DBCC CHECKDB<\/em> ran without finding any corruptions.<\/p>\n<p>Now &#8211; what about if you&#8217;re trusting your SQL Agent jobs to run <em>DBCC CHECKDB<\/em> for you every so often (how often is a whole other discussion&#8230;) and relying on the Agent job failing if <em>DBCC CHECKDB<\/em> finds corruptions. An Agent job WILL fail if a <em>DBCC CHECKDB<\/em> within it finds corruptions because <em>DBCC CHECKDB<\/em> will set the <em>@@ERROR<\/em>. Now here is a real issue &#8211; the Job History that&#8217;s captured will not contain all the output from <em>DBCC CHECKDB<\/em> &#8211; especially if you didn&#8217;t use the <em>WITH NO_INFOMSGS<\/em> option. You should make sure you capture the output to a file to avoid having to go back and run <em>DBCC CHECKDB<\/em> all over again.<\/p>\n<p>Summary &#8211; make sure you really know when <em>DBCC CHECKDB<\/em> runs successfully, <em>without<\/em> finding any corruptions!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Edit: From 2016 SP2 onward, you can use SELECT DATABASEPROPERTYEX (\u2018dbname\u2019 , \u2018LastGoodCheckDbTime\u2019 ); instead] This came up several times during the week so I thought it was about time to blog about it. One of the new features we put into SQL Server 2005 was storing the last time that DBCC CHECKDB completed successfully [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,30,31,34,85],"tags":[],"class_list":["post-1070","post","type-post","status-publish","format-standard","hentry","category-checkdb-from-every-angle","category-corruption","category-database-maintenance","category-dbcc","category-sql-agent"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CHECKDB From Every Angle: When did DBCC CHECKDB last run successfully? - Paul S. Randal<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CHECKDB From Every Angle: When did DBCC CHECKDB last run successfully? - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"[Edit: From 2016 SP2 onward, you can use SELECT DATABASEPROPERTYEX (\u2018dbname\u2019 , \u2018LastGoodCheckDbTime\u2019 ); instead] This came up several times during the week so I thought it was about time to blog about it. One of the new features we put into SQL Server 2005 was storing the last time that DBCC CHECKDB completed successfully [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2008-03-13T20:32:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-18T20:38:27+00:00\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/\",\"name\":\"CHECKDB From Every Angle: When did DBCC CHECKDB last run successfully? - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2008-03-13T20:32:17+00:00\",\"dateModified\":\"2021-09-18T20:38:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CHECKDB From Every Angle: When did DBCC CHECKDB last run successfully?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/paul\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CHECKDB From Every Angle: When did DBCC CHECKDB last run successfully? - Paul S. Randal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/","og_locale":"en_US","og_type":"article","og_title":"CHECKDB From Every Angle: When did DBCC CHECKDB last run successfully? - Paul S. Randal","og_description":"[Edit: From 2016 SP2 onward, you can use SELECT DATABASEPROPERTYEX (\u2018dbname\u2019 , \u2018LastGoodCheckDbTime\u2019 ); instead] This came up several times during the week so I thought it was about time to blog about it. One of the new features we put into SQL Server 2005 was storing the last time that DBCC CHECKDB completed successfully [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/","og_site_name":"Paul S. Randal","article_published_time":"2008-03-13T20:32:17+00:00","article_modified_time":"2021-09-18T20:38:27+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/","name":"CHECKDB From Every Angle: When did DBCC CHECKDB last run successfully? - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2008-03-13T20:32:17+00:00","dateModified":"2021-09-18T20:38:27+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-when-did-dbcc-checkdb-last-run-successfully\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"CHECKDB From Every Angle: When did DBCC CHECKDB last run successfully?"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/1070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=1070"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/1070\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=1070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=1070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=1070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}