http://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version/
Problem
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. 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:
Could not open new database 'DatabaseName'. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 1
The database 'DatabaseName' cannot be opened because it is version 655. This server supports version 611 and earlier. A downgrade path is not supported.
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. SQL Server does not allow you to restore or attach a database from a higher version of SQL Server to a lower version 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.
Solution
The error message in the problem statement occurs because the SQL Server database files (*.mdf, *.ndf and *.ldf) and backups are not backward compatible. 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:
- Generate Scripts wizard of SQL Server Management Studio
- SQL Server Integration Services
- Custom scripting and BCP
In this tip we will use the Generate Scripts wizard of SQL Server Management Studio. Here are the basic steps we need to follow:
- Script the database schema in higher version of SQL Server by using the Generate Scripts wizard of SQL Server Management Studio interface.
- 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.
In the next section, I will demonstrate the steps for downgrading a SQL Server 2012 database to SQL Server 2008 R2 database.
Step-by-Step Demo: Downgrading a SQL Server 2012 database to SQL Server 2008 R2
Step-1: Script the schema of the OUTLANDER database on the SQL Server 2012 instance (IITCUK\DEV01) using theGenerate Scripts wizard of the SQL Server Management Studio interface.
In Object Explorer connect to IITCUK\DEV01, right-click OUTLANDER database, expand Tasks and choose"Generate Scripts...".
![In Object Explorer, right-click OUTLANDER database, expand Tasks and choose](https://i-blog.csdnimg.cn/blog_migrate/e23ccb94d70733e79088c9f5c2b7d37c.jpeg)
This launches Generate and Publish Scripts wizard. Click Next, to skip the Introduction screen and proceed to theChoose Objects page.
![SQL Server Management Generate and Publish Scripts Wizard - Introduction Screen](https://i-blog.csdnimg.cn/blog_migrate/c6b910a2bd478739ab2363717e1ae2a0.jpeg)
On the Choose Objects page, choose option "Script entire database and all database objects", and then clickNext to proceed to "Set Scripting Options" page.
![Choose option Script entire database and all database objects in the SQL Server Management Studio Generate Scripts Wizard](https://i-blog.csdnimg.cn/blog_migrate/1d73882ef39d68b2233bd7c496593128.jpeg)
On the Set Scripting Options page, specify the location where you want to save the script file, and then choose theAdvanced button.
![Choose option Specifying scripting options in the SQL Server Management Studio Generate Scripts Wizard](https://i-blog.csdnimg.cn/blog_migrate/835f1b2c391057447dfcd0d72b0e1b53.jpeg)
In Advanced Scripting Options dialog box, set Script Triggers, Indexes and Primary Key options to True, Script for Server Version to SQL Server 2008 R2, and Types of data to script to Schema and Data. This last option is key because this is what generates the data per table.
![Choose option Set scripting options including scripting the Schema and Data](https://i-blog.csdnimg.cn/blog_migrate/b7e86410572c246a3de757cd0dfc5e41.jpeg)
Once done, click OK, to close Advanced Scripting Options dialog box and return to Set Scripting Options page. InSet Scripting Options page, click Next to continue to Summary page.
After reviewing your selections on Summary page, click Next to generate scripts.
![Generate and Publish Scripts - Summary Interface](https://i-blog.csdnimg.cn/blog_migrate/41a46ebc29233eb92c16582eb43787f5.jpeg)
Once scripts are generated successfully, choose the Finish button to close the Generate and Publish Scripts wizard.
![Generate and Publish Scripts wizard iterating through each object](https://i-blog.csdnimg.cn/blog_migrate/585cb1f3f016faf2e68e112123a6e4e5.jpeg)
Step-2: 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 OUTLANDER database schema and copy its data.
In Object Explorer connect to IITCUK\SQLServer2008, then in SQL Server Management Studio, open the SQL Server script you saved in Step-1.
![SSMS](https://i-blog.csdnimg.cn/blog_migrate/d52a74c4c48266c77f46c86992e4c9f9.jpeg)
![Opening SQL Script to install OUTLANDER database](https://i-blog.csdnimg.cn/blog_migrate/6f3c7ce375ba25858002501780ea5ca7.jpeg)
![Opening SQL Script to install OUTLANDER database](https://i-blog.csdnimg.cn/blog_migrate/433e2b2184c3a42d7eb131b0dee32608.jpeg)
Modify the script, to specify the correct location for the OUTLANDER database data and log files. Once done, run the script to create the OUTLANDER database on IITCUK\SQLServer2008 instance.
![Restoring OUTLANDER database](https://i-blog.csdnimg.cn/blog_migrate/86de2c0a34e820deedb90b6cf1fb95b7.jpeg)
Upon successful execution, refresh the Database folder in Object Explorer. As you can see in the following imageOUTLANDER database has been successfully downgraded.
![Verifying OUTLANDER database downgrade](https://i-blog.csdnimg.cn/blog_migrate/be874fe7e1fa2d77180d0c5b580d1d42.jpeg)
Next Steps
- To avoid this issue, always make sure that you perform a full backup of the database before you upgrade the SQL Server and database to a higher version of SQL Server. In addition, be sure to thoroughly test the application prior to releasing the application to the users.
- Consider this downgrade option as your last option to rollback from an upgrade because the time and storage needed can be very large.
- With a very large database be sure you have sufficient storage to support the data needs.
- Be sure to verify row and object counts as well as test your application before releasing to production.
- Additional Resources: