• Relational Database Service

rds
  1. Help Center
  2. Relational Database Service
  3. User Guide
  4. Working with RDS for Microsoft SQL Server
  5. Migrating SQL Server Data Using SQL Server Management Studio
  6. Importing Data

Importing Data

This section describes how to use an ECS or a device that can access RDS to connect to a DB instance and import the exported SQL file into RDS.

If the source database contains the full-text index, you need to create one on RDS.

Procedure

  1. Use sqlcmd to import the database objects.

    The Microsoft SQL Server database or client provides sqlcmd.

    >sqlcmd -S "server" -d database -U login_id -i inputfile

    • -S indicates the IP address and port of the RDS DB instance.
    • -d indicates the name of the database to be imported.
    • -U indicates the username used to log in to the database.
    • -i indicates the SQL file to be executed.

    Enter the database password as prompted.

    Example:

    >sqlcmd -S "10.65.60.79,8636" -d test -U rdsuser -i C:\test\objects.sql

    Enter the database password as prompted.

  2. Use bcp to import data.

    >bcp dbname.schema_name.table_name in C:\test\table_name.txt -n -S Server -U username -b 2000

    • -in indicates the directory which the data is imported to.
    • -n indicates that the native (database) data types are used for performing bulk-copy operations.
    • -S indicates the address to be used by the bcp tool to connect to the Microsoft SQL Server DB instance.
    • -U indicates the database username.
    • -b indicates the lines of data imported in a batch.

    Example:

    C:\test>bcp test.dbo.t1 in c:\test\t1.txt -n -S "10.65.60.79,8636" -U rdsuser -b 2000

    Enter the database password as prompted.