Sergey Nivens - Fotolia


Get faster Azure T-SQL queries using the new database query editor

Microsoft has recently added a SQL Database Query editor to its Azure cloud service. Expert Michael Otey walks you through the new T-SQL development process step-by-step.

Microsoft has been making rapid improvements to Azure. It wasn't that long ago that the Azure SQL Database implementation...

significantly lagged behind the on-premises version. That's all changed, as Microsoft now put its most recent enhancements and upgrades into Azure before bringing them into the on-premises product. Even so, one of the areas where Azure SQL Database lagged behind on-premises SQL Server was in the area of T-SQL development.

To write and test T-SQL queries for Azure SQL Database, you needed to open a remote connection to the Azure SQL Database using traditional on-premises tools like SQL Server Management Studio or Visual Studio. Microsoft recently changed that with the introduction of the SQL Database Query Editor for Azure.

The SQL Database Query Editor is currently in preview mode. It is a browser-based tool that you can run directly from the Azure portal, and it enables you to write and run queries for T-SQL development on your Azure SQL Databases and SQL Data Warehouses. There's no need to connect using remote client tools and there's no need to configure network connections or firewall rules making your T-SQL development for cloud and mobile apps easier and more streamlined.

Starting the Query Editor

The Azure Query Editor works with either Azure SQL Database or Azure SQL Data Warehouse databases. To see the Azure Query Editor in action, first open the Azure portal. Select the SQL Databases blade from the Azure menu and then navigate to the Azure SQL Database that you want to work with. Next, click on the Tools command and then click Query editor (preview) option like you see in Figure 1.

Starting Query Editor

Before you begin using the Query Editor, you need to log in to Azure SQL Database using the login button at the top of the Query Editor window. You can log in using either Azure Active Directory authentication or an Azure SQL Database login. After logging in, you can begin developing T-SQL queries in the Query Editor like you see in Figure 2.

Using T-SQL queries

As you can see in Figure 2, the Azure Query Editor provides full T-SQL syntax highlighting, helpful in T-SQL development. It also displays any T-SQL errors with a green underscore. Notably, it does not provide IntelliSense code completion. You can use the Query Editor to execute any supported T-SQL statements, including creating and dropping tables, stored procedures and other database objects as well as displaying and changing table data. While the right mouse key doesn't offer cut-and-paste functionality, you can use the Ctrl-C, Ctrl-V and Ctrl-X keyboard shortcuts to copy, paste and cut text, respectively, in the Editor pane. To execute all the T-SQL statements in the Editor pane, you can click the Run button at the top of the Query Editor window. You can also use the mouse to highlight the group of statements that you want to run and then click the Run button.

Query results are displayed in the Results pane that you can see in the bottom portion of the Query Editor window. You can use the mouse to scroll through the rows in the Results pane. You can resize the Results pane by dragging the bar between the Editor and Results sections up or down. You can also filter the results by keyword by entering the text to filter next to the eyeglass icon. All runtime messages are displayed in the Messages pane that is automatically displayed if your statements return an error, or you can click on the Messages link to see the status of your commands.

You can use the Open query and Save query options at the top of the Query Editor window to open and save the queries that you've developed. Selecting the Save query option opens the browser's Save and Save As dialogs that will allow you to save a query to your local system. By default, queries are saved with the file extension of .sql. Using the Open query option displays a file open dialog that enables you to select a local file to load into the Query Editor.

The Azure SQL Database Query Editor gives you a direct link into Azure for your T-SQL development queries. You can learn more about the preview release of the SQL Database Query Editor here.

Next Steps

Getting started with Azure database as a service

Use the Azure Blob storage service

Five tool choices for developing with Azure

Dig Deeper on Big data, machine learning and AI