Pages

Wednesday, August 24, 2022

Convert Database between SQL Versions

 

Introduction

In this article, we will show you how to restore a backup database from a higher/newer version of SQL Server. While the example below restores a SQL Server 2017 database to a SQL Server 2008 environment, the procedure applies as long as you are going from a newer version of SQL Server to an older version.

 

 

Example

1. Open SQL Server Management Studio (SSMS) and connect to your SQL server.

2. Expand Databases and right-click the database you want to back up.

 

expand.PNG

 

3. Select Tasks > Generate Scripts...

 

1-tasks-generate_scripts.png

 

3. Click Next.

 

2-generate_script_next.png

 

4. Select Script entire database and all database objects and then click Next.

 

3-Choose_objects.png

 

5. Set the File Name and Path and then click Advanced.

 

4-click_advanced.png

 

6. Set the following:

 

  • Script for Server Version to SQL Server 2008
  • Script Object-Level Permissions to True
  • Types of data to script to Schema and data

 

7. Click OK.

 

Sqlserverchange.png

 

8. Click Next.

 

6-Review_selections.png

 

9. After the scripts have been saved or published, click Finish.

 

7-Finish.png

 

10. Copy the script file to the target database environment.

 

8-Add_script_to_environment.png

 

10. Edit the file to replace ALL target database file paths with your own database environment path.

 

9-Edit_script.png

 

11. Run the following SQL command in a command prompt as Administrator:

 

1
sqlcmd -<target server name> -i C:\<your file here>.sql -<output filename>

 

Note: If your target database instance is not the default SQL instance, you need to use the complete ServerName\InstanceName for <target server name>.

 

10-command_prompt.png

 

12. Open SSMS to see if the database has been properly restored in the target environment.

No comments:

Post a Comment

Convert Database between SQL Versions

  Introduction In this article, we will show you how to restore a backup database from a higher/newer version of SQL Server. While the examp...