Skip to content

Commit 656dcdf

Browse files
authored
Merge pull request #106672 from stevestein/sqldb-query-3-5-20
sqldb - update query editor page
2 parents d1d76eb + 55a82f2 commit 656dcdf

File tree

2 files changed

+58
-50
lines changed

2 files changed

+58
-50
lines changed
112 KB
Loading
Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: "Azure portal: Query using Query Editor"
3-
description: Learn how to connect to SQL Database in the Azure portal by using the SQL Query Editor. Then, run Transact-SQL (T-SQL) statements to query and edit data.
4-
keywords: connect to sql database,azure portal, portal, query editor
2+
title: Query a SQL Database using the query editor in the Azure portal
3+
description: Learn how to use the Query Editor to run Transact-SQL (T-SQL) queries against an Azure SQL Database.
4+
keywords: connect to sql database,query sql database, azure portal, portal, query editor
55
services: sql-database
66
ms.service: sql-database
77
ms.subservice: development
@@ -11,80 +11,86 @@ ms.topic: quickstart
1111
author: Ninarn
1212
ms.author: ninarn
1313
ms.reviewer: carlrab
14-
ms.date: 10/24/2019
14+
ms.date: 03/12/2020
1515
---
16-
# Quickstart: Use the Azure portal's SQL query editor to connect and query data
16+
# Quickstart: Use the Azure portal's query editor to query a SQL database
17+
18+
The query editor is a tool in the Azure portal for running SQL queries against your Azure SQL database or Azure SQL Data Warehouse.
19+
20+
In this quickstart, you'll use the query editor to run Transact-SQL (T-SQL) queries against an Azure SQL database.
1721

18-
The SQL query editor is an Azure portal browser tool providing an easy way to execute SQL queries on your Azure SQL Database or Azure SQL Data Warehouse. In this quickstart, you'll use the query editor to connect to a SQL database and then run Transact-SQL statements to query, insert, update, and delete data.
1922

2023
## Prerequisites
2124

22-
To complete this tutorial, you need:
25+
Completing this quickstart requires the AdventureWorksLT sample database. If you don't have a working copy of the AdventureWorksLT SQL database, the following quickstart quickly creates one:
2326

24-
- An Azure SQL database. You can use one of these quickstarts to create and then configure a database in Azure SQL Database:
27+
- [Quickstart: Create a single Azure SQL database using the Azure portal, PowerShell, or Azure CLI](sql-database-single-database-get-started.md)
2528

26-
|| Single database |
27-
|:--- |:--- |
28-
| Create| [Portal](sql-database-single-database-get-started.md) |
29-
|| [CLI](scripts/sql-database-create-and-configure-database-cli.md) |
30-
|| [PowerShell](scripts/sql-database-create-and-configure-database-powershell.md) |
31-
| Configure | [Server-level IP firewall rule](sql-database-server-level-firewall-rule.md)|
32-
|||
29+
### Configure network settings
3330

34-
> [!NOTE]
35-
> The query editor uses ports 443 and 1443 to communicate. Please ensure you have enabled outbound HTTPS traffic on these ports. You will also need to add your outbound IP address to the server's allowed firewall rules to access your databases and data warehouses.
31+
If you get one of the following errors in the query editor: *Your local network settings might be preventing the Query Editor from issuing queries. Please click here for instructions on how to configure your network settings*, or *A connection to the server could not be established. This might indicate an issue with your local firewall configuration or your network proxy settings*, the following important information should help resolve:
3632

37-
## Sign in the Azure portal
33+
> [!IMPORTANT]
34+
> The query editor uses ports 443 and 1443 to communicate. Ensure you have enabled outbound HTTPS traffic on these ports. You also need to [add your outbound IP address to the server's allowed firewall rules](sql-database-server-level-firewall-rule.md) to access your databases and data warehouses.
3835
39-
Sign in to the [Azure portal](https://portal.azure.com/).
4036

41-
## Connect using SQL authentication
37+
## Open the SQL Database Query Editor
4238

43-
1. Go to the Azure portal to connect to a SQL database. Search for and select **SQL databases**.
39+
1. Sign in to the [Azure portal](https://portal.azure.com/) and select the SQL database you want to query.
4440

45-
![Navigate to SQL database list, Azure portal](./media/sql-database-connect-query-portal/search-for-sql-databases.png)
41+
2. In the **SQL database** menu, select **Query editor (preview)**.
4642

47-
2. Select your SQL database.
43+
![find query editor](./media/sql-database-connect-query-portal/find-query-editor.PNG)
4844

49-
![Select a SQL database, Azure portal](./media/sql-database-connect-query-portal/select-a-sql-database.png)
5045

51-
3. In the **SQL database** menu, select **Query editor (preview)**.
46+
## Establish a connection to the database
5247

53-
![find query editor](./media/sql-database-connect-query-portal/find-query-editor.PNG)
48+
Even though you're signed into the portal, you still need to provide credentials to access the SQL database. You can connect using SQL authentication or Azure Active Directory to connect to your database.
49+
50+
### Connect using SQL Authentication
5451

55-
4. In the **Login** page, under the **SQL server authentication** label, enter the **Login** ID and **Password** of the server admin account used to create the database. Then select **OK**.
52+
1. In the **Login** page, under **SQL server authentication**, enter a **Login** and **Password** for a user that has access to the database. If you're not sure, use the login and password for the Server admin of the database's server.
5653

5754
![sign in](./media/sql-database-connect-query-portal/login-menu.png)
5855

59-
## Connect using Azure Active Directory
56+
2. Select **OK**.
6057

61-
Configuring an Azure Active Directory (Azure AD) administrator enables you to use a single identity to sign in to the Azure portal and your SQL database. Follow the steps below to configure an Azure AD admin for your SQL server.
58+
59+
### Connect using Azure Active Directory
60+
61+
Configuring an Azure Active Directory (Azure AD) administrator enables you to use a single identity to sign in to the Azure portal and your SQL database. To connect to your database using Azure AD, follow the steps below to configure an Azure AD admin for your SQL server.
6262

6363
> [!NOTE]
6464
> * Email accounts (for example, outlook.com, gmail.com, yahoo.com, and so on) aren't yet supported as Azure AD admins. Make sure to choose a user created either natively in the Azure AD, or federated into the Azure AD.
6565
> * Azure AD admin sign in doesn't work with accounts that have 2-factor authentication enabled.
6666
67-
1. On the Azure portal menu or from the **Home** page, select **All resources**.
67+
#### Set an Active Directory admin for the database server
6868

69-
2. Select your SQL server.
69+
1. In the Azure portal, select your SQL server.
7070

71-
3. From the **SQL server** menu, under **Settings**, select **Active Directory admin**.
71+
2. On the **SQL server** menu, select **Active Directory admin**.
7272

73-
4. From the SQL server **Active Directory admin** page toolbar, select **Set admin** and choose the user or group as your Azure AD admin.
73+
3. On the SQL server **Active Directory admin** page toolbar, select **Set admin** and choose the user or group as your Azure AD admin.
7474

7575
![select active directory](./media/sql-database-connect-query-portal/select-active-directory.png)
7676

77-
5. From the **Add admin** page, in the search box, enter a user or group to find, select it as an admin, and then choose the **Select** button.
77+
4. On the **Add admin** page, in the search box, enter a user or group to find, select it as an admin, and then choose the **Select** button.
78+
79+
5. Back in the SQL server **Active Directory admin** page toolbar, select **Save**.
7880

79-
6. Back in the SQL server **Active Directory admin** page toolbar, select **Save**.
81+
### Connect to the database
8082

81-
7. In the **SQL server** menu, select **SQL databases**, and then select your SQL database.
83+
6. In the **SQL server** menu, select **SQL databases**, and then select your SQL database.
8284

83-
8. In the **SQL database** menu, select **Query editor (preview)**. In the **Login** page, under the **Active Directory authentication** label, a message appears saying you have been signed in if you're an Azure AD admin. Then select the **Continue as** *\<your user or group ID>* button.
85+
7. In the **SQL database** menu, select **Query editor (preview)**. In the **Login** page, under the **Active Directory authentication** label, a message appears saying you have been signed in if you're an Azure AD admin. Then select the **Continue as** *\<your user or group ID>* button. If the page indicates that you have not successfully logged in, you may need to refresh the page.
8486

85-
## View data
87+
## Query a SQL database
8688

87-
1. After you're authenticated, paste the following SQL in the query editor to retrieve the top 20 products by category.
89+
The following example queries should run successfully against the AdventureWorksLT sample database.
90+
91+
### Run a SELECT query
92+
93+
1. Paste the following query into the query editor:
8894

8995
```sql
9096
SELECT TOP 20 pc.Name as CategoryName, p.name as ProductName
@@ -93,13 +99,15 @@ Configuring an Azure Active Directory (Azure AD) administrator enables you to us
9399
ON pc.productcategoryid = p.productcategoryid;
94100
```
95101

96-
2. On the toolbar, select **Run** and then review the output in the **Results** pane.
102+
2. Select **Run** and then review the output in the **Results** pane.
97103

98104
![query editor results](./media/sql-database-connect-query-portal/query-editor-results.png)
99105

100-
## Insert data
106+
3. Optionally, you can save the query as a .sql file, or export the returned data as a .json, .csv, or .xml file.
107+
108+
### Run an INSERT query
101109

102-
Run the following [INSERT](https://msdn.microsoft.com/library/ms174335.aspx) Transact-SQL statement to add a new product in the `SalesLT.Product` table.
110+
Run the following [INSERT](/sql/t-sql/statements/insert-transact-sql/) T-SQL statement to add a new product in the `SalesLT.Product` table.
103111

104112
1. Replace the previous query with this one.
105113

@@ -127,9 +135,9 @@ Run the following [INSERT](https://msdn.microsoft.com/library/ms174335.aspx) Tra
127135
2. Select **Run** to insert a new row in the `Product` table. The **Messages** pane displays **Query succeeded: Affected rows: 1**.
128136

129137

130-
## Update data
138+
### Run an UPDATE query
131139

132-
Run the following [UPDATE](https://msdn.microsoft.com/library/ms177523.aspx) Transact-SQL statement to modify your new product.
140+
Run the following [UPDATE](/sql/t-sql/queries/update-transact-sql/) T-SQL statement to modify your new product.
133141

134142
1. Replace the previous query with this one.
135143

@@ -141,9 +149,9 @@ Run the following [UPDATE](https://msdn.microsoft.com/library/ms177523.aspx) Tra
141149

142150
2. Select **Run** to update the specified row in the `Product` table. The **Messages** pane displays **Query succeeded: Affected rows: 1**.
143151

144-
## Delete data
152+
### Run a DELETE query
145153

146-
Run the following [DELETE](https://msdn.microsoft.com/library/ms189835.aspx) Transact-SQL statement to remove your new product.
154+
Run the following [DELETE](/sql/t-sql/statements/delete-transact-sql/) T-SQL statement to remove your new product.
147155

148156
1. Replace the previous query with this one:
149157

@@ -159,23 +167,23 @@ Run the following [DELETE](https://msdn.microsoft.com/library/ms189835.aspx) Tra
159167

160168
There are a few things to know when working with the query editor.
161169

162-
* The query editor uses ports 443 and 1443 to communicate. Please ensure you have enabled outbound HTTPS traffic on these ports. You will also need to add your outbound IP address to the server's allowed firewall rules to access your databases and data warehouses.
170+
* The query editor uses ports 443 and 1443 to communicate. Ensure you have enabled outbound HTTPS traffic on these ports. You will also need to add your outbound IP address to the server's allowed firewall rules to access your databases and data warehouses.
163171

164172
* Query Editor works with Private Link without needing to add the Client Ip address into the SQL Database firewall
165173

166-
* Pressing F5 refreshes the query editor page and any query being worked on is lost.
174+
* Pressing **F5** refreshes the query editor page and any query being worked on is lost.
167175

168176
* Query editor doesn't support connecting to the `master` database.
169177

170178
* There's a 5-minute timeout for query execution.
171179

172180
* The query editor only supports cylindrical projection for geography data types.
173181

174-
* There's no support for IntelliSense for database tables and views. However, the editor does support autocomplete on names that have already been typed.
182+
* There's no support for IntelliSense for database tables and views, but the editor does support autocomplete on names that have already been typed.
175183

176184

177185

178186

179187
## Next steps
180188

181-
To learn more about the Transact-SQL supported in Azure SQL databases, see [Resolving Transact-SQL differences during migration to SQL Database](sql-database-transact-sql-information.md).
189+
To learn more about the Transact-SQL (T-SQL) supported in Azure SQL databases, see [Resolving Transact-SQL differences during migration to SQL Database](sql-database-transact-sql-information.md).

0 commit comments

Comments
 (0)