Query SQL Database with query editor in the Azure portal - Azure SQL Database (2024)

  • Article

Applies to: Query SQL Database with query editor in the Azure portal - Azure SQL Database (1) Azure SQL Database

The Azure SQL Database query editor (preview) is a tool to run SQL queries against Azure SQL Database in the Azure portal. In this quickstart, you connect to an Azure SQL database in the Azure portal and use query editor to run Transact-SQL (T-SQL) queries.

  • If you don't already have an Azure SQL Database created, visit Quickstart: Create a single database. Look for the option to use your offer to try Azure SQL Database for free (preview).

Prerequisites

Authentication

You need an account with permissions to connect to the database and query editor. You can use SQL authentication or Microsoft Entra ID) authentication (recommended). For more information on creating and managing logins in Azure SQL database, visit Authorize database access.

For more information about public network access, TLS version settings, and connection policy, see Azure SQL connectivity settings.

Firewall rule

For public connections to the query editor, you need to add your outbound IP address to the server's allowed firewall rules to access your databases.

If you receive this error, use the following steps to resolve:

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 the quick steps below, or for more information, see add your outbound IP address to the server's allowed firewall rules.

  1. Return to the Overview page of your SQL database.
  2. Select the link for the Azure SQL logical server next to Server name.
  3. In the Resource menu, under Security, select Networking.
  4. 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.
  5. Under Firewall rules, select Add your client IPv4 address.
    • If necessary, identify your IPv4 address and provide it in the Start and End fields.
  6. Select Save.

For troubleshooting, see Connection error troubleshooting.

Connect to the query editor

Connect to your database within the query editor.

  1. Navigate to your SQL database in the Azure portal. For example, visit your Azure SQL dashboard.

  2. On your SQL database Overview page, select Query editor (preview) from the resource menu.

    Query SQL Database with query editor in the Azure portal - Azure SQL Database (2)

  3. 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:

  • Quickstart: Use Azure Data Studio to connect and query Azure SQL Database
  • Quickstart: Use SSMS to connect to and query Azure SQL Database or Azure SQL Managed Instance
  • Quickstart: Use Visual Studio Code to connect and query

Query the database

On any database, execute the following query in the Query editor to return the time in UTC, the database name, and your authenticated login name.

SELECT SYSDATETIMEOFFSET(), DB_NAME(), ORIGINAL_LOGIN();

Query the AdventureWorksLT sample database

This portion of quickstart uses the AdventureWorksLT sample database in an Azure SQL database. If you don't have one already, you can create a database using sample data in Azure SQL Database. Look for the option to use your offer to try Azure SQL Database for free (preview).

On the Query editor (preview) page, run the following example queries against your AdventureWorksLT sample database.

Tip

New to Azure SQL Database? Get up to speed with in-depth free training content: Azure SQL Fundamentals or review the Azure SQL glossary of terms.

For more information about T-SQL in Azure SQL Database, visit T-SQL differences between SQL Server and Azure SQL Database.

Run a SELECT query

  1. To query for the top 20 products in the database, paste the following SELECT query into the query editor:

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

  3. 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.

  1. In the query editor, replace the previous query with the following query:

    INSERT INTO [SalesLT].[Product] ( [Name] , [ProductNumber] , [Color] , [ProductCategoryID] , [StandardCost] , [ListPrice] , [SellStartDate] )VALUES ('myNewProduct' ,123456789 ,'NewColor' ,1 ,100 ,100 ,GETDATE() );
  2. Select Run to add the new product. After the query runs, the Messages pane displays Query succeeded: Affected rows: 1.

Run an UPDATE query

Run the following UPDATE T-SQL statement to update the price of your new product.

  1. In the query editor, replace the previous query with the following query:

    UPDATE [SalesLT].[Product]SET [ListPrice] = 125WHERE Name = 'myNewProduct';
  2. Select Run to update the specified row in the Product table. The Messages pane displays Query succeeded: Affected rows: 1.

Run a DELETE query

Run the following DELETE T-SQL statement to remove your new product.

  1. In the query editor, replace the previous query with the following query:

    DELETE FROM [SalesLT].[Product]WHERE Name = 'myNewProduct';
  2. Select Run to delete the specified row in the Product table. The Messages pane displays Query succeeded: Affected rows: 1.

Related content

  • Query editor (preview)
  • Quickstart: Create a single database
  • Azure SQL connectivity settings
Query SQL Database with query editor in the Azure portal - Azure SQL Database (2024)

FAQs

Is there a query editor available for SQL database on Azure? ›

The query editor is designed for lightweight querying and object exploration in your Azure SQL database, all from within the browser in the Azure portal. You can run T-SQL queries against your database, as well as edit data in the build-in tabular data editor.

How do I query a SQL database in Azure portal? ›

Connect to the query editor
  1. Navigate to your SQL database in the Azure portal. For example, visit your Azure SQL dashboard.
  2. On your SQL database Overview page, select Query editor (preview) from the resource menu.
  3. On the sign-in screen, provide credentials to connect to the database.
Apr 16, 2024

Where is query editor in Azure portal? ›

Query editor is placed under the database main tab as shown below. In the connection setting screen, the query editor allows us three types of authentication: SQL Server authentication. Active Directory password authentication.

Which command line tool can you use to query Azure SQL databases? ›

You can try the sqlcmd utility from Azure Cloud Shell, as it's preinstalled by default: Launch Cloud Shell.

Which SQL is used in Azure SQL Database? ›

Azure SQL Database is based on the latest stable version of the Microsoft SQL Server database engine. You can use advanced query processing features, such as high-performance in-memory technologies and intelligent query processing.

How do I open SQL query editor? ›

Right-click on your database connection and select SQL Editor -> Recent SQL script from the context menu or go to SQL Editor -> Recent SQL script from the main menu. Alternatively use the Ctrl+Enter shortcut in the Database Navigator view. A Choose SQL Script window appears. Click any script to open it in a new tab.

How to use query in Azure? ›

To run any query, expand a folder and choose the title of the query. The view opens to display the query Results. You can also run a query by using the Azure DevOps command line interface. The Queries page, as with other web portal pages, remembers the view you last went to and returns you to that view.

How do I access my SQL database in Azure? ›

Connect to an Azure SQL Database or Azure SQL Managed Instance
  1. Start SQL Server Management Studio (SSMS). ...
  2. The Connect to Server dialog box appears. ...
  3. After you complete all the fields, select Connect.
Feb 29, 2024

How to connect to Azure SQL Database from command line? ›

To get started with sqlcmd, open the command prompt and enter sqlcmd followed by the connection string for your Synapse SQL database. The connection string requires the following parameters: Server (-S): Server in the form < Server Name > -ondemand.sql.azuresynapse.net(Serverless SQL pool) or < Server Name > .

How do I open query editor? ›

There are two ways to do this.
  1. Select Data > Get Data > From Other Sources > Blank Query.
  2. Select Data > Get Data > Launch Power Query Editor.

Where is SQL Server query editor? ›

The SQL query editor provides a text editor to write queries using T-SQL. To access the built-in SQL query editor: Select the Query icon located at the bottom of the warehouse editor window.

How to get data from Azure SQL Database? ›

Prerequisites for receiving data into Azure SQL Database or Azure Synapse Analytics (formerly Azure SQL DW)
  1. In the Azure portal, navigate to your SQL server. ...
  2. Select Yes for Allow Azure services and resources to access this server.
  3. Select +Add client IP. ...
  4. Select Save.
Dec 19, 2023

How to connect SQL Server to Azure SQL Database? ›

To connect to SQL Azure with SQL Server Management Studio:
  1. Open SQL Server Management Studio. ...
  2. Replace "server_name" with your assigned server. ...
  3. Press Connect. ...
  4. Click OK and after that press the Cancel of the LogOn dialog.
  5. Click the New Query action in the SSMS toolbar.
  6. Again, you will be presented with a logon dialog.

How do I trace a SQL query in Azure SQL Database? ›

Run a trace with Profiler
  1. On the File menu, select New Trace.
  2. Enter the name of your managed instance as the Server name. ...
  3. After Authentication, select Windows Authentication.
  4. Select Connect.
  5. Follow the steps in Create a Trace (SQL Server Profiler) to configure the trace.
  6. Select Run after configuring the trace.
Sep 29, 2023

Which Azure cli command creates an Azure SQL Database? ›

az sql db create

Does Azure SQL have SQL Agent? ›

SQL Agent is not available in Azure SQL Database. Pipelines with recurring triggers can be used for T-SQL script automation in Azure Synapse Analytics. Pipelines with recurring triggers are based on Azure Data Factory.

How to do a Query in Azure? ›

To run any query, expand a folder and choose the title of the query. The view opens to display the query Results. You can also run a query by using the Azure DevOps command line interface. The Queries page, as with other web portal pages, remembers the view you last went to and returns you to that view.

How do I create a table in Azure Query editor? ›

Create a table
  1. In the navigation pane, select Query.
  2. Select + Add > Table or right-click on the database where you want to create the table and select Create table.
Mar 11, 2024

Which two of the following tools can be used to Query data held in Azure SQL Database? ›

Which two of the following tools can be used to query data held in Azure SQL Database? Azure Data Studio. The query editor in the Azure portal.

Top Articles
Fluff up the old mulch instead of adding more: Ask the Ground Crew
The financial situation of Hertha BSC Berlin
Xre-02022
Global Foods Trading GmbH, Biebesheim a. Rhein
English Bulldog Puppies For Sale Under 1000 In Florida
Craigslist St. Paul
Teenbeautyfitness
Steamy Afternoon With Handsome Fernando
Fototour verlassener Fliegerhorst Schönwald [Lost Place Brandenburg]
Boat Jumping Female Otezla Commercial Actress
Hope Swinimer Net Worth
Med First James City
Operation Cleanup Schedule Fresno Ca
9044906381
Truck Trader Pennsylvania
boohoo group plc Stock (BOO) - Quote London S.E.- MarketScreener
Sport-News heute – Schweiz & International | aktuell im Ticker
Craigslist Free Stuff Merced Ca
10 Fun Things to Do in Elk Grove, CA | Explore Elk Grove
Hennens Chattanooga Dress Code
The best firm mattress 2024, approved by sleep experts
Samantha Aufderheide
Woodmont Place At Palmer Resident Portal
Bill Remini Obituary
Nk 1399
031515 828
10 Best Quotes From Venom (2018)
Craigslist Middletown Ohio
Promatch Parts
Http://N14.Ultipro.com
Moxfield Deck Builder
Prima Healthcare Columbiana Ohio
Hisense Ht5021Kp Manual
Anya Banerjee Feet
One Main Branch Locator
Rs3 Bis Perks
Gt500 Forums
Restored Republic June 6 2023
Questions answered? Ducks say so in rivalry rout
Nid Lcms
Brandon Spikes Career Earnings
Babykeilani
Bmp 202 Blue Round Pill
Enr 2100
Rise Meadville Reviews
bot .com Project by super soph
New Zero Turn Mowers For Sale Near Me
Marcel Boom X
The Plug Las Vegas Dispensary
Grandma's Portuguese Sweet Bread Recipe Made from Scratch
Olay Holiday Gift Rebate.com
Latest Posts
Article information

Author: Kerri Lueilwitz

Last Updated:

Views: 6309

Rating: 4.7 / 5 (47 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Kerri Lueilwitz

Birthday: 1992-10-31

Address: Suite 878 3699 Chantelle Roads, Colebury, NC 68599

Phone: +6111989609516

Job: Chief Farming Manager

Hobby: Mycology, Stone skipping, Dowsing, Whittling, Taxidermy, Sand art, Roller skating

Introduction: My name is Kerri Lueilwitz, I am a courageous, gentle, quaint, thankful, outstanding, brave, vast person who loves writing and wants to share my knowledge and understanding with you.