Migrate to Innovate Summit:
Learn how migrating and modernizing to Azure can boost your business's performance, resilience, and security, enabling you to fully embrace AI.Register now
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In this quickstart, connect to an Azure SQL database in the Azure portal and use query editor to run Transact-SQL (T-SQL) queries. The Azure SQL Database query editor (preview) is a tool to run SQL queries against Azure SQL Database in the Azure portal.
You need an account with permissions to connect to the database and query editor. You can use SQL authentication or Microsoft Entra authentication (recommended). For more information on creating and managing logins in Azure SQL database, see Authorize database access.
Firewall rule
If you receive this error: Cannot open server 'server-name' requested by the login. Client with IP address 'xx.xx.xx.xx' is not allowed to access the server. To enable access, use the Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect.
Follow these quick steps:
Return to the Overview page of your SQL database.
Select the link for the Azure SQL logical server next to Server name.
In the Resource menu, under Security, select Networking.
Ensure that under Public network access, the Selected networks option is selected.
If this is a test or temporary environment, set the option to Selected networks.
If not, access must be granted through other means than covered in this quickstart, likely via private endpoints (by using Azure Private Link) as outlined in the network access overview.
Under Firewall rules, select Add your client IPv4 address.
If necessary, identify your IPv4 address and provide it in the Start and End fields.
On your SQL database Overview page, select Query editor (preview) from the resource menu.
On the sign-in screen, provide credentials to connect to the database.
You can connect using SQL or Microsoft Entra authentication.
To connect with SQL authentication, under SQL server authentication, enter a Login and Password for a user that has access to the database, and then select OK. You can always use the login and password for the server admin.
To connect using Microsoft Entra ID, if you're the Microsoft Entra server admin, select Continue as <user@domain>. If sign-in is unsuccessful, try refreshing the page.
Connection with other tools
You can also connect to your Azure SQL database using other tools, including:
To query for the top 20 products in the database, paste the following SELECT query into the query editor:
SQL
SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName
FROM SalesLT.ProductCategory pc
JOIN SalesLT.Product p
ON pc.productcategoryid = p.productcategoryid;
Select Run, and then review the output in the Results pane.
Optionally, you can select Save query to save the query as an .sql file, or select Export data as to export the results as a .json, .csv, or .xml file.
Run an INSERT query
To add a new product to the SalesLT.Product table, run the following INSERT T-SQL statement.
In the query editor, replace the previous query with the following query:
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.