Migrating Data from a Self-Managed SQL Server Database on an ECS to an RDS for SQL Server DB Instance
Scenarios
- You have created a Microsoft SQL Server database on an ECS.
- The self-managed SQL Server database version on the ECS cannot be later than the version of the RDS for SQL Server DB instance.
- You have installed the SQL Server Management Studio (SSMS).
Procedure
- Create an ECS.
The ECS and the RDS DB instance must be in the same region and VPC.
- Install Microsoft SQL Server 2008, 2012, or 2014 on the ECS.
The Microsoft SQL Server installed on the ECS must be Standard or Enterprise Edition. It is recommended that the Microsoft SQL Server version be the same as the RDS DB instance version.
- Upload a local .bak file to the ECS and use Microsoft SQL Server to restore the local file to the RDS DB instance.
- Use the script generation tool provided by Microsoft SQL Server to generate a database structure script.
- Right-click the database whose schema script needs to be generated and choose Tasks > Generate Scripts.
- On the Choose Objects page, choose database objects to script, as shown in Figure 1. Then, click Next.
- On the Set Scripting Options page, specify a directory for saving the script.
You are advised to save the script locally and generate an SQL script for execution.
Figure 2 Specifying a directory for saving the script
- Click Advanced. In the displayed Advanced Scripting Options dialog box, specify scripting options for triggers, indexes, unique keys, the primary key, and server version. Then, click OK.
Figure 3 Specifying advanced scripting options
Generate Script for Dependent Objects indicates the script data type option.
- Click Next to generate the script.
- Use the SSMS client to connect to the RDS DB instance and open the generated SQL script.
You need to create an empty database, and then use the script to create structures in the database.
- Use the import and export function provided by Microsoft SQL Server to migrate data.
- Right-click the database where data is to be imported and choose Tasks > Import Data.
- Click Next.
- On the Choose a Data Source page, select a data source and click Next.
- On the Choose a Destination page, select a destination database and click Next.
- Destination: Select SQL Server Native Client (depending on your destination database type).
- Server name: Enter the IP address and port number of the destination DB instance.
- Authentication: Select Use SQL Server Authentication. Then, set User name to rdsuser, and Password to the password of rdsuser.
- Database: Select the destination database where data is to be imported.
- Select Copy data from one or more tables or views and click Next.
- On the Select Source Tables and Views page, select the tables and views that you want to copy. Then, click Edit Mappings. In the displayed dialog box, select Enable identity insert and edit mappings based on your requirements.
- Click Next.
- Select Run immediately and click Next.
- Click Finish to import data. You can view the progress. About 4,000 rows can be processed per second.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot