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.

Connect to the query editor

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.

  1. 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).

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

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

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

  4. On the sign-in screen, provide credentials to connect to the database.

    • Azure SQL databases exist inside logical SQL servers.

      • You can connect to the logical SQL server's master using a login, then connect to your database.
      • Or, using a contained user, you can connect directly to your Azure SQL 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 <your user or group ID>. 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
  • Configure and manage Microsoft Entra authentication with Azure SQL

Firewall rule

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

Try adding your IP address to the Azure SQL logical server firewall. Follow the quick steps before, 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.
    1. If this is a test or temporary environment, set the option to Selected networks.
    2. 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.
    1. If necessary, identify your IPv4 address and provide it in the Start and End fields.
  6. Select Save.

For more on information to configure your local firewall, see Azure portal Query editor for Azure SQL Database.

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();

Tip

New to Azure SQL Database? Get up to speed with in-depth free training content: Azure SQL Fundamentals.

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.

On the Query editor (preview) page, run the following example queries against your AdventureWorksLT sample 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.

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

  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)
  • What is Azure SQL?
  • Azure SQL glossary of terms
  • T-SQL differences between SQL Server and Azure SQL Database
  • Quickstart: Create a single database
  • Try Azure SQL Database for free (preview)
  • Azure SQL connectivity settings
Query SQL Database with query editor in the Azure portal - Azure SQL Database (2024)
Top Articles
Supply Chain Strategy: Back to Basics
Why Do Students Drop Out of Computer Science Studies?
Data reveals most expensive dog breeds in U.S. for 2024 
Pikes Suwanee
Fbsm St Louis
World War II: Summary, Combatants & Facts | HISTORY
Q-global Web-based Administration, Scoring, and Reporting
Fredatmcd.read.inkling.com
Wal-Mart 2516 Directory
Critiques de la série Z Nation
Phat Ass Ebony
Page 4444 – Christianity Today
Welcome To Aces Charting
Ilcc Number Lookup
Die eID-Karte für Bürgerinnen und Bürger der EU und des EWR
Michelle_Barbelle
Snohomish Hairmasters
Oviedo Anonib
Southern Food Buffet Near Me
Netherlands Toys, Games & Hobbies | ExpatINFO Holland
Eos Fitness Irvine
Battle for Azeroth Preview: Drustvar Visitor’s Guide - WoW
Sevierville, Tennessee: Idyllisches Reiseziel in den Great Smoky Mountains
Will Certifier Crossword Clue
The "Minus Sign (−)" Symbol in Mathematics
Pge Outage Map Beaverton
Reahub 1 Twitter
Berklee College Of Music Academic Calendar
Forza Horizon 5: 8 Best Cars For Rally Racing
Dynasty League Forum
Volkswagen For Sale Craigslist
Panty Note 33
Brake Masters 228
Craigslist Pets Seattle Tacoma Washington
Mathsspot.com Unblocked Roblox Online Unblocked
Craigslist Ct Apartments For Rent
Rinehart Sons Funeral Home
Restaurants Near 275 Tremont St Boston
R/Sandiego
Shop e.chi, Energie Welle, Energie Sohle, E-Smog Kissen, Hologramm
Sparkle Nails Phillipsburg
Lily Starfire White Christmas
Tj Nails Victoria Tx
Sarah Colman-Livengood Park Raytown Photos
Huntington Bank Review 2024 | Bankrate
Sierra At Tahoe Season Pass Costco
Norwegian Luna | Cruise Ship
24 Hour Arrest List Knox County
Nuefliks.com
Vinoteca East Rutherford Menu
What Is Opm1 Treas 310 Deposit
Latest Posts
Article information

Author: Dan Stracke

Last Updated:

Views: 6023

Rating: 4.2 / 5 (43 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Dan Stracke

Birthday: 1992-08-25

Address: 2253 Brown Springs, East Alla, OH 38634-0309

Phone: +398735162064

Job: Investor Government Associate

Hobby: Shopping, LARPing, Scrapbooking, Surfing, Slacklining, Dance, Glassblowing

Introduction: My name is Dan Stracke, I am a homely, gleaming, glamorous, inquisitive, homely, gorgeous, light person who loves writing and wants to share my knowledge and understanding with you.