Quickly create and use an ApsaraDB RDS for SQL Server instance
This tutorial describes how to quickly create an ApsaraDB RDS for SQL Server instance in the console, configure database and account information, and connect to the instance using various methods to get started with ApsaraDB RDS for SQL Server.
If you are new to ApsaraDB RDS, we recommend that you first read about the limits of ApsaraDB RDS.
Prerequisites
If you use a Resource Access Management (RAM) user to create an RDS instance, the AliyunRDSFullAccess and AliyunBSSOrderAccess policies must be attached to the RAM user. For more information, see Use RAM for resource authorization.
Costs
When you create an ApsaraDB RDS for SQL Server instance, you are charged for the instance type and storage. The fees depend on parameters such as the billing method, instance edition, instance type, storage class, and storage capacity.
1. Quickly create an RDS SQL Server instance
This tutorial describes how to use the Quick Creation method to create an RDS SQL Server instance in the console. Unlike the Standard Creation method, the Quick Creation method lets you create an instance by configuring only the key parameters. This method is designed to help you get started quickly. For more information about how to configure other parameters when you create an instance, see Create an RDS SQL Server instance.
Go to the RDS Management Console and click Create Instance. The RDS instance purchase page opens.
At the top of the purchase page, select Quick Creation.
Select Billing Method. RDS for SQL Server offers two billing methods. The scenarios and features of each method are as follows:
Billing Method
Scenario
Benefits
Subscription
Long-term use of an ApsaraDB RDS for SQL Server instance.
The subscription billing method is more cost-effective than the pay-as-you-go billing method. The longer the subscription duration, the higher the discount.
Pay-as-you-go
Short-term use of an ApsaraDB RDS for SQL Server instance.
You can release the instance at any time to stop billing.
Alternatively, you can create a Pay-as-you-go instance. After you confirm that the instance meets your requirements, you can change the billing method from pay-as-you-go to subscription.
Select the Region in which to create the RDS instance.
ImportantYou cannot change the region after you purchase an RDS instance. Choose the region carefully.
If you have purchased an Elastic Compute Service (ECS) instance and want the ECS instance to connect to the RDS instance over an internal network, select the same region as the ECS instance. Otherwise, the ECS instance can access the RDS instance only over the public network, which prevents optimal performance.
If you want to connect to the RDS instance from a device other than an ECS instance, such as a local server or computer, create the RDS instance in a region close to that device to reduce network latency. You can then connect to the RDS instance using its public endpoint.
Select Engine. This tutorial demonstrates the steps using a SQL Server database.
Select an Instance Type.
RDS SQL Server offers a variety of instance types that you can select as needed. If an instance type does not meet your needs, you can change the configuration after the instance is created or select Standard Creation at the top of the page to create a custom instance. For more information, see Create an RDS SQL Server instance.
Select an Instance Type.
Select a Category (general-purpose, dedicated, or shared). The available instance types vary depending on the instance edition and version. The options displayed in the console prevail.
Category
Description
Features
General-purpose
Dedicated: memory and I/O
Shared: CPU and storage
Cost-effective
Dedicated
Dedicated: CPU, memory, storage, and I/O
Note
The dedicated-host type is the top-tier configuration of the dedicated category. It exclusively uses the CPU, memory, storage, and I/O resources of an entire physical server.
Provides superior and stable performance
Note
The basic edition does not support dedicated instance types.
Shared
Dedicated: memory, storage
Shared: CPU
Cost-effective for workloads with lower stability requirements
Select a specific instance type based on parameters such as the number of CPU cores, memory size, and maximum number of connections.
NoteFor a list of specifications, see Instance types for primary ApsaraDB RDS for SQL Server instances.
Set the network and vSwitch. The network type is set to Virtual Private Cloud (VPC) by default.
ImportantIf the VPC is the same but the vSwitch is different, the ECS instance and the RDS instance can still communicate over the internal network.
You cannot change the VPC after the instance is created. To connect to the RDS instance from an ECS instance over an internal network, make sure they are in the same region and use the same VPC.
(Optional) View additional configuration items. In Quick Creation mode, Alibaba Cloud automatically configures other parameters by default. You can click More Configurations (Optional) to view these settings.
Select the Quantity of instances. The Quick Creation feature lets you purchase up to 10 instances at a time. For this tutorial, the default value is 1.
(Optional) If you set the Billing Method to Subscription, you must also set the Duration.
You can also select Enable Auto-renewal to prevent service interruptions due to expiration.
Click Confirm Order and proceed to payment.
To view the instance, go to the Instance List page. At the top of the page, select the region where the instance is located and find the instance by its Creation Time.
2. Create a database
Go to the ApsaraDB RDS Instances list. In the top navigation bar, select the region where you created the instance in Step 1. Then, click the ID of the target instance.
In the left navigation pane, click Database Management, and then click the Create Database button.
In the panel that appears, set the database parameters.
For this tutorial, set the Database Name to
dbtestand the Supported Character Set to Chinese_PRC_CI_AS. Then, click Create.You can view the newly created database on the Database Management page, or after you connect to the SQL Server instance.
3. Create an account
On the instance details page, click Accounts in the left navigation pane.
Click Password Policy to set the password validity period for accounts and enhance account security.
NoteShared and Serverless instances do not support setting a custom password policy. You can skip this step for these types of instances and proceed to the next one.
Click Create Account. In the pop-up panel, set the account parameters.
NoteAn error may occur if the account name is a duplicate or if you create accounts too frequently, such as before the previous account creation is complete. If this happens, check whether the account name is a duplicate or wait for the previous account creation to finish before you create the next account.
Enter a value for Database Account. For this tutorial, the value for Database Account is
testuser.Select an Account Type. RDS for SQL Server lets you create Privileged Account, Standard Account, and Super Privileged Accounts. This tutorial uses a Privileged Account as an example. For more information, see Create other types of accounts.
ImportantThe first account for an ApsaraDB RDS for SQL Server instance must be a privileged account, and each instance is allowed to have only one privileged account. This account has read and write permissions for all databases on the instance. If the creation fails, you may already have a privileged account on your instance.
In the New Password and Confirm Password fields, enter your new password.
Apply the password policy set in Step 2 to this privileged account.
Click OK to create your account.
Refresh the Accounts page to view the newly created privileged account.
4. Configure secure access to the instance
If you plan to log on to the database using the command line or a client, you must first add the IP address of your ECS instance or on-premises device to the IP whitelist of the ApsaraDB RDS for SQL Server instance. Then, obtain the internal or public endpoint of the instance based on the access type to connect to the instance. If you plan to log on to the database using Alibaba Cloud DMS, you can proceed directly to Step 5.
4.1 Set an IP whitelist
On the instance details page, click Whitelist and SecGroup in the navigation pane on the left.
Click Create Whitelist, enter a Group Name, and add the application server's IP address to the whitelist group.
Click OK to save the whitelist configuration.
You can refresh the Whitelist and SecGroup page to view the newly added whitelists.
4.2 Select a connection type
Connection types are divided into internal network access and public network access. If your setup meets the conditions for internal network access, you must use the instance's internal endpoint for a remote connection. If your setup does not meet the conditions or you are using an on-premises device to access the ApsaraDB RDS for SQL Server instance, you must use the instance's public endpoint. The conditions for internal network access and the methods for obtaining internal and public endpoints are as follows:
To access the instance over an internal network, your setup must meet the following conditions:
You are using an Alibaba Cloud server, and the server and the RDS instance are in the same region and use the same network type.
If the network type for both the server and the instance is VPC, they must have the same VPC ID.
Scenario | RDS Instance Endpoint to Obtain | How to Obtain |
Meets the conditions for internal network access | RDS internal endpoint | On the instance details page, click Database Connection in the navigation pane on the left to view the instance address and port number. Note The public endpoint is displayed only after you click Enable Public Endpoint. |
Accessing the RDS instance from an ECS instance, but the conditions for internal network access are not met | RDS public endpoint | |
Accessing the RDS instance from an on-premises device |
5. Connect to the ApsaraDB RDS for SQL Server instance
You can log on to the SQL Server database directly using Alibaba Cloud DMS, connect remotely using a client, or connect using a Java application.
Method 1: Log on to the instance using DMS
Data Management (DMS) is a one-stop data management platform that supports the entire data lifecycle. It provides features such as global data asset management, data governance, database design and development, data integration, data development, and data consumption. The built-in Data Disaster Recovery feature of DMS also provides low-cost and high-reliability backup and recovery capabilities to help enterprises efficiently and securely extract data value and accelerate their digital transformation.
You can use DMS to quickly and conveniently log on to an ApsaraDB RDS for SQL Server instance for data management and use without needing to configure the instance's IP whitelist or select a connection type.
Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.
Click Log On to Database to navigate to the DMS logon page.

In the Log on to Instance dialog box, enter the logon information and click Log on.
For Access Mode, select Account and Password Logon as an example.
Enter the Database Account and Database Password. For this tutorial, use the privileged account
testuserand a user-defined password.Select a Control Mode. In this example, select Flexible Management.
NoteFlexible Management is free of charge. Stable Change and Security Collaboration incur fees.
Compared to the control mode of Flexible Management, Stable Change and Security Collaboration offer more features and enhanced database control. If you are evaluating ApsaraDB RDS for SQL Server, we recommend using the Flexible Management mode.
After a successful logon, you can view the newly created database in the Logged-in Instances list on the left side of the DMS page. This tutorial uses the
dbtestdatabase as an example. You can also double-click another database to switch to it.NoteIf the instance exists but the target database is not found in the DMS logged-in instance list, it may be for one of the following reasons:
The logon account does not have permission to access the target database: Go to the Accounts page on the RDS instance details page and click Actions in the Change Permissions column for the target account to grant permissions.
The directory cannot be displayed because metadata is not synchronized: Hover the pointer over the instance to which the target database belongs. Click the
button to the right of the instance name to refresh the database list and display the target database.
After you successfully log on to the SQL Server database in DMS, you can create databases, create tables, and query and change table data in the SQL Console.
Method 2: Connect to the instance using the SSMS client
Microsoft SQL Server Management Studio (SSMS) is a graphical interface tool for managing and working with SQL Server. It can be used to connect to different SQL Server databases, including ApsaraDB RDS for SQL Server instances, on-premises SQL Server instances, or SQL Server instances in the cloud.
This tutorial uses Microsoft SQL Server Management Studio 19.0 (SSMS) as an example to show you how to connect to an ApsaraDB RDS for SQL Server instance using a client.
We recommend that you download the latest version of the client to support all SQL Server versions.
Connecting to an instance using a client requires you to preset an IP whitelist and obtain the instance's connection address as needed.
Open the local Microsoft SQL Server Management Studio 19.0 (SSMS) client.
Select Connect > Database Engine.
Enter the logon information in the Connect to Server dialog box.

Parameter
Value in this tutorial
Description
Server name
rm-2ze****.rds.aliyuncs.com,1433
The endpoint and port number of the RDS instance. Enter the Public Endpoint and Public Port obtained when you enabled the public endpoint. Separate the endpoint and port number with a comma (,).
Authentication
SQL Server Authentication
The authentication method for SQL Server.
Login Name
testuser
Enter the account name of the RDS instance.
Password
Test_pw123
Enter the password for the RDS instance account.
To connect to the instance, click Connect.
After a successful connection, the database connection information is displayed on the left side of SSMS.

Method 3: Connect to the instance using a Java application
The following section describes how to connect to an ApsaraDB RDS for SQL Server instance using a Java application with JDBC.
Before you connect to the database, add the IP address of the application's runtime environment, such as an ECS instance or an on-premises device, to the IP whitelist of the ApsaraDB RDS for SQL Server instance. For more information, see Set a whitelist.
Add the Microsoft JDBC driver to your Maven project to access the SQL Server database.
Write the sample code to connect to the SQL Server database using Java, as follows:
Replace the endpoint, database name, username, password, and SQL command in the example with your actual information. For more information, see View or change the endpoint and port number.
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.sql.ResultSet; public class testMSSQLJDBC { public static void main(String[] args) { // Enter the database endpoint. Use the internal endpoint if the application is deployed on an ECS instance. Use the public endpoint if it is deployed locally or in another environment. String url = "jdbc:sqlserver://rm-2vc367d081200******.mssql.cn-chengdu.rds.aliyuncs.com:1433;" + "database=YourDatabaseName;" + "encrypt=true;" + "trustServerCertificate=true;" + "loginTimeout=30;"; // The username and password. You must specify them if you do not use Windows Authentication. String username = "usernametest"; String password = "Passwordtest!"; // Create a connection object. Connection connection = null; try { // Load the JDBC driver. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); // Establish a connection to the SQL Server database. connection = DriverManager.getConnection(url, username, password); System.out.println("Connection successful!"); // Create a Statement object to execute SQL commands. Statement statement = connection.createStatement(); // Execute an SQL query. Replace the table name and column names as needed. String sql = "SELECT TOP 10 * FROM YourTableName"; ResultSet resultSet = statement.executeQuery(sql); // Process the result set. while (resultSet.next()) { System.out.println("Column 1: " + resultSet.getString("YourColumnName1")); System.out.println("Column 2: " + resultSet.getString("YourColumnName2")); } // Close the result set. resultSet.close(); // Close the Statement object. statement.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { // Close the connection. if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } } }Test whether the connection is successful.
Save the above code as a
SqlServerConnection.javafile. Compile and run the program in the command line or an IDE. If the configuration is correct, the program outputs a result similar to the following, which indicates that the program has successfully connected to the SQL Server database.
Next steps
FAQ
How do I view the total number of RDS instances under my Alibaba Cloud account?
Log on to the RDS Overview page. It shows the total number of RDS instances for all database engines under your account, the regions where they are located, and the number of running instances per region.
Why can't I see the instance I just created in the instance list?
| Cause | Description | Resolution |
|---|---|---|
| Incorrect region | The current region does not match the region selected during instance creation. | Switch to the correct region in the upper-left corner of the page. |
| Insufficient resources in the zone | The instance failed to create due to insufficient resources. A refund appears in the Orders list if creation fails. | Select a different zone and try again. |
| RAM policy prohibits unencrypted instances | A RAM policy is configured to block unencrypted RDS instance creation. This affects: (1) instances with a high-performance local disk — disk encryption cannot be set at creation time; (2) instances with a cloud disk where disk encryption was not enabled. For details, see Use a RAM policy to restrict RAM user permissions. | Set the storage type to cloud disk, enable Disk Encryption, select a key, and try again. |
References
Standard creation method: Create an ApsaraDB RDS for SQL Server instance
Create an RDS instance using an API: CreateDBInstance
For more information about how to create other types of instances, see the following topics:






