{"id":2778,"date":"2016-05-20T10:08:24","date_gmt":"2016-05-20T10:08:24","guid":{"rendered":"http:\/\/radixcloud.com\/?p=2778"},"modified":"2016-05-20T10:08:24","modified_gmt":"2016-05-20T10:08:24","slug":"how-to-corrupt-your-database","status":"publish","type":"post","link":"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/","title":{"rendered":"How to corrupt your database"},"content":{"rendered":"<p>In the highly unlikely world of DBA testing scenarios, sometimes you will need to corrupt your MS SQL database. One of these scenarios could be that you want to check how long it would take to recover the database during disaster recovery. What will be described here is only for testing purposes and MUST NOT be done on any production system. The entire process was conducted on a local test environment.<\/p>\n<p>There are several procedures which you can use, mainly through updating the status of the database in the system tables, which does not always work. There are cases where the needed options are deprecated in the SQL version, for example, in MS SQL Server 2005, the extended option that would allow running modification queries against the system tables was removed. I ran into this particular case when I tried to make a SUSPECT database on a MS SQL Server 2008 R2. Even though the statement to allow updates went smoothly:<\/p>\n<p><em>sp_configure &#8220;allow updates&#8221;, 1<\/em><\/p>\n<p>When I tried to change the status of the database named Prime:<\/p>\n<p><em>UPDATE sysdatabases SET STATUS = 320 WHERE name = \u2018Prime\u2019<\/em><\/p>\n<p>I received the following error:<\/p>\n<p><em>Msg 259, Level 16, State 1, Line 1<\/em><\/p>\n<p><em>Ad hoc updates to system catalogs are not allowed.<\/em><\/p>\n<p>In that particular moment, I did not have the time to troubleshoot this error, and I needed the Prime database marked as SUSPECT.<\/p>\n<p>As it turns out, the easiest way to get a SUSPECT database is to mess up the files. This works regardless of the MS SQL version.<\/p>\n<p>&nbsp;<\/p>\n<p>First, restore a database from a good backup. In my Management Studio, I have the Prime database which I intend to place in a SUSPECT status:<\/p>\n<p><a href=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-1.png\" rel=\"attachment wp-att-2779\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-2779\" src=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-1-300x198.png\" alt=\"Image 1\" width=\"300\" height=\"198\" srcset=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-1-300x198.png 300w, https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-1.png 323w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>You can check the status of the database using the statement:<\/p>\n<p><em>select databasepropertyex(&#8216;Prime&#8217;, &#8216;status&#8217;)<\/em><\/p>\n<p><a href=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-2.png\" rel=\"attachment wp-att-2780\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-2780\" src=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-2-300x98.png\" alt=\"Image 2\" width=\"352\" height=\"115\" srcset=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-2-300x98.png 300w, https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-2.png 513w\" sizes=\"(max-width: 352px) 100vw, 352px\" \/><\/a><\/p>\n<p>Or see if you can list and query the tables. So my Prime database is now ONLINE, which means that it is alive and well.<\/p>\n<p>Next, shut down the MS SQL services from the Services panel in Windows.<\/p>\n<p>Locate the .ldf file of your database. In my case, this is the Prime_log.ldf file. Open the file for editing (I used Notepad):<\/p>\n<p><a href=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-3.png\" rel=\"attachment wp-att-2781\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-2781\" src=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-3-300x192.png\" alt=\"Image 3\" width=\"300\" height=\"192\" srcset=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-3-300x192.png 300w, https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-3.png 365w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>And make an adjustment. I added a new row in the file and typed 12345:<\/p>\n<p><a href=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-4.png\" rel=\"attachment wp-att-2782\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-2782\" src=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-4-300x169.png\" alt=\"Image 4\" width=\"300\" height=\"169\" srcset=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-4-300x169.png 300w, https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-4.png 320w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Save the file and start the MS SQL services again. Open the Management Studio and execute the statement to check the database status again:<\/p>\n<p><a href=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-5.png\" rel=\"attachment wp-att-2783\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-2783\" src=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-5-300x140.png\" alt=\"Image 5\" width=\"300\" height=\"140\" srcset=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-5-300x140.png 300w, https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-5.png 386w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>As you can see, the Prime database is now a SUSPECT \ud83d\ude00<\/p>\n<p>If you try to expand the database node, you will get the following error:<\/p>\n<p><a href=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-6.png\" rel=\"attachment wp-att-2784\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-2784\" src=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-6-300x58.png\" alt=\"Image 6\" width=\"357\" height=\"69\" srcset=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-6-300x58.png 300w, https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-6.png 611w\" sizes=\"(max-width: 357px) 100vw, 357px\" \/><\/a><\/p>\n<p>Congratulations, you have successfully corrupted your database \ud83d\ude00<\/p>\n<p>&nbsp;<\/p>\n<p>Jana Georgievska,<\/p>\n<p>DBA<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>In the highly unlikely world of DBA testing scenarios, sometimes you will need to corrupt your MS SQL database. One of these scenarios could be that you want to check [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[25,49,52,57,19,50,56,51,55,54,53],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to corrupt your database | Radix Cloud<\/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:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to corrupt your database | Radix Cloud\" \/>\n<meta property=\"og:description\" content=\"In the highly unlikely world of DBA testing scenarios, sometimes you will need to corrupt your MS SQL database. One of these scenarios could be that you want to check [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/\" \/>\n<meta property=\"og:site_name\" content=\"Radix Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/radixtechnologies\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-20T10:08:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-1-300x198.png\" \/>\n<meta name=\"author\" content=\"Hristijan Peshevski\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@RadixCloud\" \/>\n<meta name=\"twitter:site\" content=\"@RadixCloud\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hristijan Peshevski\" \/>\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\":\"Article\",\"@id\":\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/\"},\"author\":{\"name\":\"Hristijan Peshevski\",\"@id\":\"https:\/\/radixcloud.com\/en\/#\/schema\/person\/cee27ca63bcfe60ba72cd3ee0f2a894e\"},\"headline\":\"How to corrupt your database\",\"datePublished\":\"2016-05-20T10:08:24+00:00\",\"dateModified\":\"2016-05-20T10:08:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/\"},\"wordCount\":439,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/radixcloud.com\/en\/#organization\"},\"keywords\":[\"Cloud\",\"database\",\"DBA\",\"DBA Management\",\"IT\",\"management\",\"MS SQL\",\"Prime Database\",\"Servers\",\"SQL\",\"Testing\"],\"articleSection\":[\"News Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/\",\"url\":\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/\",\"name\":\"How to corrupt your database | Radix Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/radixcloud.com\/en\/#website\"},\"datePublished\":\"2016-05-20T10:08:24+00:00\",\"dateModified\":\"2016-05-20T10:08:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/radixcloud.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to corrupt your database\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/radixcloud.com\/en\/#website\",\"url\":\"https:\/\/radixcloud.com\/en\/\",\"name\":\"Radix Cloud\",\"description\":\"Managed Services for the Cloud\",\"publisher\":{\"@id\":\"https:\/\/radixcloud.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/radixcloud.com\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/radixcloud.com\/en\/#organization\",\"name\":\"Radix Cloud Technologies\",\"url\":\"https:\/\/radixcloud.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/radixcloud.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/radixcloud.com\/wp-content\/uploads\/2015\/08\/radix_cloud_logo_x2.png\",\"contentUrl\":\"https:\/\/radixcloud.com\/wp-content\/uploads\/2015\/08\/radix_cloud_logo_x2.png\",\"width\":298,\"height\":120,\"caption\":\"Radix Cloud Technologies\"},\"image\":{\"@id\":\"https:\/\/radixcloud.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/radixtechnologies\",\"https:\/\/twitter.com\/RadixCloud\",\"https:\/\/www.linkedin.com\/company\/radix-technologies_2?trk=nav_account_sub_nav_company_admin\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/radixcloud.com\/en\/#\/schema\/person\/cee27ca63bcfe60ba72cd3ee0f2a894e\",\"name\":\"Hristijan Peshevski\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/radixcloud.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/95ce1c5411326181c8518f8413c43bc0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/95ce1c5411326181c8518f8413c43bc0?s=96&d=mm&r=g\",\"caption\":\"Hristijan Peshevski\"},\"url\":\"https:\/\/radixcloud.com\/en\/author\/kiko\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to corrupt your database | Radix Cloud","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:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/","og_locale":"en_US","og_type":"article","og_title":"How to corrupt your database | Radix Cloud","og_description":"In the highly unlikely world of DBA testing scenarios, sometimes you will need to corrupt your MS SQL database. One of these scenarios could be that you want to check [&hellip;]","og_url":"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/","og_site_name":"Radix Cloud","article_publisher":"https:\/\/www.facebook.com\/radixtechnologies","article_published_time":"2016-05-20T10:08:24+00:00","og_image":[{"url":"https:\/\/radixcloud.com\/wp-content\/uploads\/2016\/05\/Image-1-300x198.png"}],"author":"Hristijan Peshevski","twitter_card":"summary_large_image","twitter_creator":"@RadixCloud","twitter_site":"@RadixCloud","twitter_misc":{"Written by":"Hristijan Peshevski","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/#article","isPartOf":{"@id":"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/"},"author":{"name":"Hristijan Peshevski","@id":"https:\/\/radixcloud.com\/en\/#\/schema\/person\/cee27ca63bcfe60ba72cd3ee0f2a894e"},"headline":"How to corrupt your database","datePublished":"2016-05-20T10:08:24+00:00","dateModified":"2016-05-20T10:08:24+00:00","mainEntityOfPage":{"@id":"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/"},"wordCount":439,"commentCount":0,"publisher":{"@id":"https:\/\/radixcloud.com\/en\/#organization"},"keywords":["Cloud","database","DBA","DBA Management","IT","management","MS SQL","Prime Database","Servers","SQL","Testing"],"articleSection":["News Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/","url":"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/","name":"How to corrupt your database | Radix Cloud","isPartOf":{"@id":"https:\/\/radixcloud.com\/en\/#website"},"datePublished":"2016-05-20T10:08:24+00:00","dateModified":"2016-05-20T10:08:24+00:00","breadcrumb":{"@id":"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/radixcloud.com\/en\/2016\/05\/20\/how-to-corrupt-your-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/radixcloud.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to corrupt your database"}]},{"@type":"WebSite","@id":"https:\/\/radixcloud.com\/en\/#website","url":"https:\/\/radixcloud.com\/en\/","name":"Radix Cloud","description":"Managed Services for the Cloud","publisher":{"@id":"https:\/\/radixcloud.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/radixcloud.com\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/radixcloud.com\/en\/#organization","name":"Radix Cloud Technologies","url":"https:\/\/radixcloud.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/radixcloud.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/radixcloud.com\/wp-content\/uploads\/2015\/08\/radix_cloud_logo_x2.png","contentUrl":"https:\/\/radixcloud.com\/wp-content\/uploads\/2015\/08\/radix_cloud_logo_x2.png","width":298,"height":120,"caption":"Radix Cloud Technologies"},"image":{"@id":"https:\/\/radixcloud.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/radixtechnologies","https:\/\/twitter.com\/RadixCloud","https:\/\/www.linkedin.com\/company\/radix-technologies_2?trk=nav_account_sub_nav_company_admin"]},{"@type":"Person","@id":"https:\/\/radixcloud.com\/en\/#\/schema\/person\/cee27ca63bcfe60ba72cd3ee0f2a894e","name":"Hristijan Peshevski","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/radixcloud.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/95ce1c5411326181c8518f8413c43bc0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/95ce1c5411326181c8518f8413c43bc0?s=96&d=mm&r=g","caption":"Hristijan Peshevski"},"url":"https:\/\/radixcloud.com\/en\/author\/kiko\/"}]}},"_links":{"self":[{"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/posts\/2778"}],"collection":[{"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/comments?post=2778"}],"version-history":[{"count":1,"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/posts\/2778\/revisions"}],"predecessor-version":[{"id":2785,"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/posts\/2778\/revisions\/2785"}],"wp:attachment":[{"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/media?parent=2778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/categories?post=2778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/radixcloud.com\/en\/wp-json\/wp\/v2\/tags?post=2778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}