In this quickstart, you'll use Azure Data Studio to connect to an Azure SQL Database server. You'll then run Transact-SQL (T-SQL) statements to create and query the TutorialDB database, which is used in other Azure Data Studio tutorials.
Note
While Microsoft Entra ID is the new name for Azure Active Directory (Azure AD), to prevent disrupting existing environments, Azure AD still remains in some hardcoded elements such as UI fields, connection providers, error codes, and cmdlets. In this article, the two names are interchangeable.
PrerequisitesTo complete this quickstart, you need Azure Data Studio, and an Azure SQL Database server.
If you don't have an Azure SQL server, complete one of the following Azure SQL Database quickstarts. Remember the fully qualified server name and sign in credentials for later steps:
Connect to your Azure SQL Database serverUse Azure Data Studio to establish a connection to your Azure SQL Database server.
The first time you run Azure Data Studio the Welcome page should open. If you don't see the Welcome page, select Help > Welcome. Select New Connection to open the Connection pane:
This article uses SQL authentication, but Microsoft Entra authentication is supported for all SQL Server products and services. Fill in the following fields using the server name, user name, and password for your Azure SQL server:
Setting Suggested value Description Server name The fully qualified server name Something like: servername.database.windows.net. Authentication SQL Login This tutorial uses SQL Authentication. User name The server admin account user name The user name from the account used to create the server. Password (SQL Login) The server admin account password The password from the account used to create the server. Save Password? Yes or No Select Yes if you don't want to enter the password each time. Database name leave blank You're only connecting to the server here. Server Group Select <Default> You can set this field to a specific server group you created.Select Connect.
If your server doesn't have a firewall rule allowing Azure Data Studio to connect, the Create new firewall rule form opens. Complete the form to create a new firewall rule. For details, see Firewall rules.
After successfully connecting, your server opens in the SERVERS sidebar.
Create the tutorial databaseThe next sections create the TutorialDB database that's used in other Azure Data Studio tutorials.
Right-click on your Azure SQL server in the SERVERS sidebar and select New Query.
Paste this SQL into the query editor.
IF NOT EXISTS (
SELECT name
FROM sys.databases
WHERE name = N'TutorialDB'
)
CREATE DATABASE [TutorialDB]
GO
ALTER DATABASE [TutorialDB] SET QUERY_STORE=ON
GO
From the toolbar, select Run. Notifications appear in the MESSAGES pane showing query progress.
The query editor is connected to the master database, but we want to create a table in the TutorialDB database.
Connect to the TutorialDB database.
Create a Customers
table.
Replace the previous query in the query editor with this one and select Run.
-- Create a new table called 'Customers' in schema 'dbo'
-- Drop the table if it already exists
IF OBJECT_ID('dbo.Customers', 'U') IS NOT NULL
DROP TABLE dbo.Customers
GO
-- Create the table in the specified schema
CREATE TABLE dbo.Customers
(
CustomerId INT NOT NULL PRIMARY KEY, -- primary key column
Name [NVARCHAR](50) NOT NULL,
Location [NVARCHAR](50) NOT NULL,
Email [NVARCHAR](50) NOT NULL
);
GO
Replace the previous query with this one and select Run.
-- Insert rows into table 'Customers'
INSERT INTO dbo.Customers
([CustomerId],[Name],[Location],[Email])
VALUES
( 1, N'Orlando', N'Australia', N''),
( 2, N'Keith', N'India', N'keith0@adventure-works.com'),
( 3, N'Donna', N'Germany', N'donna0@adventure-works.com'),
( 4, N'Janet', N'United States', N'janet1@adventure-works.com')
GO
View the result
Replace the previous query with this one and select Run.
-- Select rows from table 'Customers'
SELECT * FROM dbo.Customers;
The query results display:
Clean up resourcesLater quickstart articles build upon the resources created here. If you plan to work through these articles, be sure not to delete these resources. Otherwise, in the Azure portal, delete the resources you no longer need. For details, see Clean up resources.
Next stepsNow that you've successfully connected to an Azure SQL database and run a query, try the Code editor tutorial.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4