Quickstart: Create an Azure SQL Database single database

In this quickstart, you create a single database in Azure SQL Database using either the Azure portal, a PowerShell script, or an Azure CLI script. You then query the database using Query editor in the Azure portal.


Create a single database

This quickstart creates a single database in the serverless compute tier.

To create a single database in the Azure portal, this quickstart starts at the Azure SQL page.

  1. Browse to the Select SQL Deployment option page.

  2. Under SQL databases, leave Resource type set to Single database, and select Create.

    Add to Azure SQL

  3. On the Basics tab of the Create SQL Database form, under Project details, select the desired Azure Subscription.

  4. For Resource group, select Create new, enter myResourceGroup, and select OK.

  5. For Database name, enter mySampleDatabase.

  6. For Server, select Create new, and fill out the New server form with the following values:

    • Server name: Enter mysqlserver, and add some characters for uniqueness. We can't provide an exact server name to use because server names must be globally unique for all servers in Azure, not just unique within a subscription. So enter something like mysqlserver12345, and the portal lets you know if it's available or not.
    • Server admin login: Enter azureuser.
    • Password: Enter a password that meets requirements, and enter it again in the Confirm password field.
    • Location: Select a location from the dropdown list.

    Select OK.

  7. Leave Want to use SQL elastic pool set to No.

  8. Under Compute + storage, select Configure database.

  9. This quickstart uses a serverless database, so select Serverless, and then select Apply.

    configure serverless database

  10. Select Next: Networking at the bottom of the page.

    New SQL database - Basic tab

  11. On the Networking tab, for Connectivity method, select Public endpoint.

  12. For Firewall rules, set Add current client IP address to Yes. Leave Allow Azure services and resources to access this server set to No.

  13. Select Next: Additional settings at the bottom of the page.

    Networking tab

  14. On the Additional settings tab, in the Data source section, for Use existing data, select Sample. This creates an AdventureWorksLT sample database so there's some tables and data to query and experiment with, as opposed to an empty blank database.

  15. Optionally, enable Azure Defender for SQL.

  16. Optionally, set the maintenance window so planned maintenance is performed at the best time for your database.

  17. Select Review + create at the bottom of the page:

    Additional settings tab

  18. On the Review + create page, after reviewing, select Create.

Query the database

Once your database is created, you can use the Query editor (preview) in the Azure portal to connect to the database and query data.

  1. In the portal, search for and select SQL databases, and then select your database from the list.

  2. On the page for your database, select Query editor (preview) in the left menu.

  3. Enter your server admin login information, and select OK.

    Sign in to Query editor

  4. Enter the following query in the Query editor pane.

    SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName
    FROM SalesLT.ProductCategory pc
    JOIN SalesLT.Product p
    ON pc.productcategoryid = p.productcategoryid;
  5. Select Run, and then review the query results in the Results pane.

    Query editor results

  6. Close the Query editor page, and select OK when prompted to discard your unsaved edits.

Clean up resources

Keep the resource group, server, and single database to go on to the next steps, and learn how to connect and query your database with different methods.

When you're finished using these resources, you can delete the resource group you created, which will also delete the server and single database within it.

To delete myResourceGroup and all its resources using the Azure portal:

  1. In the portal, search for and select Resource groups, and then select myResourceGroup from the list.
  2. On the resource group page, select Delete resource group.
  3. Under Type the resource group name, enter myResourceGroup, and then select Delete.

Next steps

Connect and query your database using different tools and languages:

Want to optimize and save on your cloud spending?