Azure SQL Database Quickstarts

Welcome to the Azure SQL Database quickstarts! This guide will help you get started with creating and managing your first Azure SQL database.

Prerequisites

Steps

1

Create an Azure SQL Database Server

First, you need to create a logical server to host your databases.

1. Sign in to the Azure portal.

2. In the search bar, type "Azure SQL" and select "Azure SQL" from the services list.

3. Click on "+ Create".

4. Select "Single database" under the "SQL databases" section and click "Create".

5. On the "Basics" tab:

  • Subscription: Select your Azure subscription.
  • Resource group: Create a new one or select an existing one.
  • Server name: Enter a unique name for your server (e.g., youruniqueservername).
  • Location: Choose a region.
  • Administrator login: Create a login name.
  • Password: Create a strong password and confirm it.

6. Click "Next: Networking >".

7. Under "Network connectivity", select "Public endpoint".

8. Under "Firewall rules", select "Yes" for "Allow Azure services and resources to access this server".

9. Click "Review + create", then "Create".

2

Create a SQL Database

Now, let's create your first database on the server you just created.

1. After your server is deployed, navigate to its resource page.

2. Under "Data management", select "Databases".

3. Click "+ Create database".

4. On the "Basics" tab:

  • Subscription: Pre-selected.
  • Resource group: Pre-selected.
  • Server: Pre-selected.
  • Database name: Enter a name for your database (e.g., mydatabase).
  • Compute + storage: For this quickstart, you can select "Serverless" for a cost-effective option or choose a different tier based on your needs. Click "Configure database".

5. Click "Review + create", then "Create".

3

Connect to Your Database

Use Azure Data Studio or SSMS to connect to your new Azure SQL Database.

1. Obtain your server's fully qualified domain name (FQDN). You can find this on the server's overview page in the Azure portal under "Server name".

2. Open Azure Data Studio or SSMS.

3. Create a new connection:

  • Server: Enter the FQDN of your Azure SQL server.
  • Authentication type: Select "SQL Login".
  • User name: Enter the administrator login name you created.
  • Password: Enter the password you created.

4. Click "Connect".

4

Run a Sample Query

Once connected, you can run a simple query.

1. In your connected SQL tool, open a new query window.

2. Execute the following Transact-SQL (T-SQL) query:

SELECT @@VERSION;

3. This query will return information about your Azure SQL Database server version.

Next Steps

Congratulations! You have successfully created an Azure SQL Database and connected to it. Here are some ideas for what to do next:

Note: Remember to clean up resources if you no longer need them to avoid ongoing charges. You can delete your resource group from the Azure portal.