{"id":5375,"date":"2026-04-23T09:36:54","date_gmt":"2026-04-23T16:36:54","guid":{"rendered":"https:\/\/www.sqlskills.com\/blogs\/paul\/?p=5375"},"modified":"2026-04-23T09:36:54","modified_gmt":"2026-04-23T16:36:54","slug":"sql101-application-data-consistency-checking","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/","title":{"rendered":"SQL101: Application data consistency checking"},"content":{"rendered":"<p style=\"text-align: justify;\">It&#8217;s quite common for a company that experiences a corruption-causing disaster, but has no valid backups to restore from and no ability to fail over to a redundant secondary, to just run repair and then immediately start running in production again.<\/p>\n<p style=\"text-align: justify;\">&lt;Imagine there&#8217;s a clever GIF here combining OH NO! UH OH! OMG! SMH! NOOO!&gt;<\/p>\n<p style=\"text-align: justify;\">Over the years I\u2019ve taught countless classes and conference sessions that talk about corruption and how it happens, how to run consistency checks, using <em>DBCC CHECKDB<\/em>, and running repair.\u00a0When I\u2019m talking about repair, I explain that if you have to run <em>REPAIR_ALLOW_DATA_LOSS<\/em> and it actually deletes data records, you need to reinitialize any affected replication topologies, and validate any affected constraints. This is all documented in Books Online, but that doesn\u2019t mean that people read it and know that \u2013 lol!<\/p>\n<p style=\"text-align: justify;\">What *isn\u2019t* in Books Online, and I make sure the attendees realize, is that repair is all about making the database structurally consistent \u2013 it doesn\u2019t know anything about the data relationships between tables (either protected by constraints or just inherent in the schema design). This means that after a data-losing repair, the data relationships in the database may well be broken.<\/p>\n<p style=\"text-align: justify;\">I then always ask the audience: \u201cHow many of you have an application data-consistency checker that you can run to validate all the business rules and relationships that the application depends on? In fact, how many of you even have a way to test that the application is working correctly after running a repair or deploying new code?\u201d<\/p>\n<p style=\"text-align: justify;\">Every time I ask, I might (rarely) get one or two hands go up, out of a class of 30 or a session of 50 or more. I\u2019ve never had more than two, and usually I don\u2019t get any.<\/p>\n<p style=\"text-align: justify;\">It\u2019s just not something people think about. They assume that if repair runs correctly then they can carry on and everything will work. No.<\/p>\n<p style=\"text-align: justify;\"><strong>Call to action:<\/strong><\/p>\n<p style=\"text-align: justify;\">You really should have some way to validate that your application is running on correct data. Otherwise, in the best case, it will fail, but in the worst case, it will continue running erroneously \u2013 maybe with wrong results that affect your business.<\/p>\n<p style=\"text-align: justify;\">This basically means codifying the required relationships in constraints and\/or some code that verifies the required relationships (if they can\u2019t be expressed as relational constraints) are correct.<\/p>\n<p style=\"text-align: justify;\">If you have a third-party application, it might be hard or impossible to persuade the vendor to provide such a tool, especially if they specifically don\u2019t support running repair on their database.<\/p>\n<p style=\"text-align: justify;\">Alternative: have a bullet=;proof baclup-and-restore strategy and\/or failover solution.<\/p>\n<p style=\"text-align: justify;\"><strong>Bottom line:<\/strong> Your business depends on the applications running in the data tier, and you need to make sure, as much as you can, that they\u2019re running on correct data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s quite common for a company that experiences a corruption-causing disaster, but has no valid backups to restore from and no ability to fail over to a redundant secondary, to just run repair and then immediately start running in production again. &lt;Imagine there&#8217;s a clever GIF here combining OH NO! UH OH! OMG! SMH! NOOO!&gt; [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,35,108],"tags":[],"class_list":["post-5375","post","type-post","status-publish","format-standard","hentry","category-corruption","category-disaster-recovery","category-sql101"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SQL101: Application data consistency checking - 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\/sql101-application-data-consistency-checking\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL101: Application data consistency checking - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"It&#8217;s quite common for a company that experiences a corruption-causing disaster, but has no valid backups to restore from and no ability to fail over to a redundant secondary, to just run repair and then immediately start running in production again. &lt;Imagine there&#8217;s a clever GIF here combining OH NO! UH OH! OMG! SMH! NOOO!&gt; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-23T16:36:54+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\/sql101-application-data-consistency-checking\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/\",\"name\":\"SQL101: Application data consistency checking - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2026-04-23T16:36:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL101: Application data consistency checking\"}]},{\"@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":"SQL101: Application data consistency checking - 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\/sql101-application-data-consistency-checking\/","og_locale":"en_US","og_type":"article","og_title":"SQL101: Application data consistency checking - Paul S. Randal","og_description":"It&#8217;s quite common for a company that experiences a corruption-causing disaster, but has no valid backups to restore from and no ability to fail over to a redundant secondary, to just run repair and then immediately start running in production again. &lt;Imagine there&#8217;s a clever GIF here combining OH NO! UH OH! OMG! SMH! NOOO!&gt; [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/","og_site_name":"Paul S. Randal","article_published_time":"2026-04-23T16:36:54+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\/sql101-application-data-consistency-checking\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/","name":"SQL101: Application data consistency checking - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2026-04-23T16:36:54+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/sql101-application-data-consistency-checking\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"SQL101: Application data consistency checking"}]},{"@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\/5375","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=5375"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/5375\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=5375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=5375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=5375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}