﻿{"id":68,"date":"2014-10-14T16:30:40","date_gmt":"2014-10-14T15:30:40","guid":{"rendered":"http:\/\/www.codereview.co\/?p=68"},"modified":"2014-10-14T17:06:42","modified_gmt":"2014-10-14T16:06:42","slug":"downgrading-a-sql-server-database-to-a-lower-version","status":"publish","type":"post","link":"http:\/\/www.codereview.co\/index.php\/sql-server-tutorials\/downgrading-a-sql-server-database-to-a-lower-version\/","title":{"rendered":"Downgrading a SQL Server database to a lower version"},"content":{"rendered":"<p><strong><span style=\"color: #000000;\">Scenario proposal<\/span><\/strong><\/p>\n<p><span style=\"color: #000000;\">After recently upgrading a SQL Server instance to SQL Server 2012 a few days ago, you noticed that your application is not functioning properly. You decided to roll back the upgrade by downgrading the SQL Server database engine to SQL Server 2008 R2.\u00a0 After the downgrade of the database engine, you are unable to attach the databases or restore the backups of the databases, even though the database compatibility level is set to the downgraded version of SQL Server. You receive the following error message, when you attempt to restore the database:<\/span><\/p>\n<p><span style=\"color: #ff0000;\">Msg 1813, Level 16, State 2, Line 1 Could not open new database &#8216;DatabaseName&#8217;. CREATE DATABASE is aborted. Msg 948, Level 20, State 1, Line 1 The database &#8216;DatabaseName&#8217; cannot be opened because it is version 655. This server supports version 611 and earlier. A downgrade path is not supported.<\/span><\/p>\n<p><span style=\"color: #000000;\">This error message is generated because SQL Server automatically upgrades the database, when you restore or attach the database from lower version to higher version.\u00a0 SQL Server does not allow you to restore or attach a database from a higher version of SQL Server to a lower version\u00a0 of SQL Server. In this tip, we will look at a one time procedure which we can follow to downgrade the database from a higher version (SQL Server 2012) of SQL Server to a lower version (SQL Server 2008 R2) of SQL Server.<\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>Solution<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">The error message in the problem statement occurs because the SQL Server database files (*.mdf, *.ndf and *.ldf) and backups are not backward compatible.\u00a0 Backward compatibility is why we cannot restore or attach a database created from a higher version of SQL Server to a lower version SQL Server. However, there are a few options that can help us to downgrade the database from a higher version of SQL Server to a lower version SQL Server. These options include:<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">Generate Scripts wizard of SQL Server Management Studio<\/span><\/li>\n<li><span style=\"color: #000000;\">SQL Server Integration Services<\/span><\/li>\n<li><span style=\"color: #000000;\">Custom scripting and BCP<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">In this tip we will use the Generate Scripts wizard of SQL Server Management Studio.\u00a0 Here are the basic steps we need to follow:<\/span><\/p>\n<ul>\n<li><span style=\"color: #000000;\">Script the database schema in higher version of SQL Server by using the Generate Scripts wizard of SQL Server Management Studio interface.<\/span><\/li>\n<li><span style=\"color: #000000;\">Connect to the lower version of SQL Server, and then run the SQL scripts that were generated in the previous step, to create database schema and copy data.<\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">In the next section, I will demonstrate the steps for downgrading a SQL Server 2012 database to SQL Server 2008 R2 database.<\/span><\/p>\n<p><span style=\"color: #000000;\"><em><strong>Note:<\/strong> For demonstration purpose, I&#8217;ll be downgrading the <strong>OUTLANDER<\/strong> database hosted o<\/em><em>n my SQL Server 2012 instance (<strong>IITCUK\\DEV01<\/strong>) to SQL Server 2008 R2 instance (<strong>IITCUK\\SQLSERVER2008<\/strong>).<\/em><\/span><\/p>\n<h3><span style=\"color: #000000;\">Step-by-Step Demo: Downgrading a SQL Server 2012 database to SQL Server 2008 R2<\/span><\/h3>\n<p><span style=\"color: #000000;\"><strong>Step-1:<\/strong> Script the schema of the <strong>OUTLANDER<\/strong> database on the SQL Server 2012 instance (IITCUK\\DEV01) using the <strong>Generate Scripts<\/strong> wizard of the SQL Server Management Studio interface.<\/span><\/p>\n<p><span style=\"color: #000000;\">In <strong>Object Explorer<\/strong> connect to <strong>IITCUK\\DEV01<\/strong>, right-click <strong>OUTLANDER<\/strong> database, expand <strong>Tasks<\/strong> and choose <strong>&#8220;Generate Scripts&#8230;&#8221;<\/strong>.<\/span><\/p>\n<p><span style=\"color: #000000;\">\u00a0<span style=\"color: #000000;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-72\" src=\"http:\/\/i0.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/11.jpg?resize=286%2C300\" alt=\"1\" srcset=\"http:\/\/i0.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/11.jpg?resize=286%2C300 286w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/11.jpg 501w\" sizes=\"(max-width: 286px) 100vw, 286px\" data-recalc-dims=\"1\" \/><\/span><\/span><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">This launches <b>Generate and Publish Scripts<\/b> wizard. Click <b>Next<\/b>, to skip the <b>Introduction<\/b> screen and proceed to the <b>Choose Objects <\/b>page.<\/span><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\"><span style=\"color: #000000;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-73\" src=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/21.jpg?resize=300%2C279\" alt=\"2\" srcset=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/21.jpg?resize=300%2C279 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/21-270x250.jpg 270w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/21.jpg 491w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/span><\/span><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">On the <b>Choose Objects<\/b> page, choose option <b>&#8220;Script entire database and all database objects&#8221;<\/b>, and then click <b>Next<\/b> to proceed to <b>&#8220;Set Scripting Options&#8221;<\/b> page.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-74\" src=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/3.jpg?resize=300%2C278\" alt=\"3\" srcset=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/3.jpg?resize=300%2C278 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/3-270x250.jpg 270w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/3.jpg 495w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">On the <b>Set Scripting Options<\/b> page, specify the location where you want to save the script file, and then choose the <b>Advanced<\/b> button.<\/span><\/p>\n<p><span style=\"color: #000000;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-76\" src=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/4.jpg?resize=300%2C280\" alt=\"4\" srcset=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/4.jpg?resize=300%2C280 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/4.jpg 496w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/span><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">In <b>Advanced Scripting Options<\/b> dialog box, set Script <b>Triggers<\/b>, <b>Indexes<\/b> and <b>Primary Key<\/b> options to <b>True<\/b>, <b>Script for Server Version<\/b> to <b>SQL Server 2008 R2<\/b>, and <b>Types of data to script<\/b> to <b>Schema and Data<\/b>.\u00a0 This last option is key because this is what generates the data per table.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-77\" src=\"http:\/\/i0.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/5.jpg?resize=265%2C300\" alt=\"5\" srcset=\"http:\/\/i0.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/5.jpg?resize=265%2C300 265w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/5.jpg 446w\" sizes=\"(max-width: 265px) 100vw, 265px\" data-recalc-dims=\"1\" \/><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">Once done, click <b>OK<\/b>, to close <b>Advanced Scripting Options<\/b> dialog box and return to <b>Set Scripting Options<\/b> page. In <b>Set Scripting Options<\/b> page, click <b>Next<\/b> to continue to <b>Summary<\/b> page.<\/span><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">After reviewing your selections on <b>Summary<\/b> page, click <b>Next<\/b> to generate scripts.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-78\" src=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/6.jpg?resize=300%2C282\" alt=\"6\" srcset=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/6.jpg?resize=300%2C282 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/6.jpg 492w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">Once scripts are generated successfully, choose the\u00a0<b>Finish<\/b> button to close the <b>Generate and Publish Scripts<\/b> wizard.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-79\" src=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/7.jpg?resize=300%2C278\" alt=\"7\" srcset=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/7.jpg?resize=300%2C278 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/7-270x250.jpg 270w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/7.jpg 498w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/p>\n<p><span style=\"color: #000000; font-size: small;\"><span style=\"font-family: Verdana;\"><b>Step-2:<\/b> Connect to the SQL Server 2008 R2 instance (IITCUK\\SQLSERVER2008), and then run the SQL scripts that were generated in Step-1, to create the <b>OUTLANDER<\/b> database schema and copy its data.<\/span><\/span><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">In <b>Object Explorer<\/b> connect to <b>IITCUK\\SQLServer2008<\/b>, then in SQL Server Management Studio, open the SQL Server script you saved in Step-1.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-80\" src=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/8.jpg?resize=300%2C106\" alt=\"8\" srcset=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/8.jpg?resize=300%2C106 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/8.jpg 498w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-81\" src=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/9.jpg?resize=300%2C180\" alt=\"9\" srcset=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/9.jpg?resize=300%2C180 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/9.jpg 501w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/p>\n<p><span style=\"color: #000000;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-82\" src=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/10.jpg?resize=300%2C207\" alt=\"10\" srcset=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/10.jpg?resize=300%2C207 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/10.jpg 498w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/span><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">Modify the script, to specify the correct location for the <b>OUTLANDER<\/b> database data and log files. Once done, run the script to create the <b>OUTLANDER<\/b> database on IITCUK\\SQLServer2008 instance.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-83\" src=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/111.jpg?resize=300%2C159\" alt=\"11\" srcset=\"http:\/\/i2.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/111.jpg?resize=300%2C159 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/111.jpg 597w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/p>\n<p><span style=\"color: #000000; font-family: Verdana; font-size: small;\">Upon successful execution, refresh the <b>Database<\/b> folder in <b>Object Explorer<\/b>. As you can see in the following image <b>OUTLANDER<\/b> database has been successfully downgraded.<\/span><\/p>\n<p><span style=\"color: #000000;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-84\" src=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/12.jpg?resize=300%2C160\" alt=\"12\" srcset=\"http:\/\/i1.wp.com\/www.codereview.co\/wp-content\/uploads\/2014\/10\/12.jpg?resize=300%2C160 300w, http:\/\/www.codereview.co\/wp-content\/uploads\/2014\/10\/12.jpg 601w\" sizes=\"(max-width: 300px) 100vw, 300px\" data-recalc-dims=\"1\" \/><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>Thanks for reading this article,<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>Next steps :<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01.Add this article to your database toolkit<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.Share this with your colleagues because Sharing is Learning<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\"><strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a03.Comment below if you need any assistance<\/strong><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scenario proposal After recently upgrading a SQL Server instance to SQL Server 2012 a few days ago, you noticed that your application is not functioning properly. You decided to roll back the upgrade by downgrading the SQL Server database engine to SQL Server 2008 R2.\u00a0 After the downgrade of the database engine, you are unable [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[173,65,4,3],"tags":[8,14,15,13,12,16],"_links":{"self":[{"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/posts\/68"}],"collection":[{"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":7,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":357,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/posts\/68\/revisions\/357"}],"wp:attachment":[{"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.codereview.co\/index.php\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}