Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL database in Microsoft Fabric
Get started using SQL Server Management Studio (SSMS) to connect to your SQL database in Microsoft Fabric and run some Transact-SQL (T-SQL) commands.
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.
The article demonstrates the following steps:
- Connect to a SQL database in Fabric
- Create a table in your new database
- Insert rows into your new table
- Query the new table and view the results
- Use the query window table to verify your connection properties
- Remove database
Prerequisites
- Install SQL Server Management Studio
- You need an existing Fabric capacity. If you don't, start a Fabric trial.
- You can use an existing workspace or create a new Fabric workspace.
- You must be a member of the Admin or Member roles for the workspace to create a SQL database.
- Create a SQL database in Fabric. Start with an new, empty database.
Connect to a SQL database in Fabric
Note
Releases of SSMS prior to 18.6 don't authenticate to Database Engines through Microsoft Entra multifactor authentication (MFA). To continue using MFA, you need SSMS 18.6 or a later version.
Start SQL Server Management Studio (SSMS). The first time you run SSMS, the Connect to Server window opens. If it doesn't open, you can open it manually by selecting Object Explorer > Connect > Database Engine.
Locate the server name and database name for your SQL database in the Fabric portal.
The connection string of the SQL database is similar to the connection string of Azure SQL Database. The server name looks like
<server-unique-identifer>.database.windows.netand the database name looks like<database name>-<unique identifier>.To find the SQL connection string for your SQL database in Fabric:
Go to the settings of your SQL database item. Select Connection strings. The server name is the
Data sourceand the database name is theInitial Catalog.Or, in the item list of the workspace, select the
...menu. Select Settings then Connection strings.Or, select the Open in button and SQL Server Management Studio. The server connection information is displayed.
The Connect to Server dialog box appears. Enter the following information, all other settings can be left default:
Setting Suggested value Details Server type Database Engine Select Database Engine (usually the default option). Server name The fully qualified server name Enter the Server Name, including .database.fabric.microsoft.com,1433.Authentication Choose Microsoft Entra MFA. For more information, see Authentication in SQL database in Microsoft Fabric. Database Name Provide the database name of your SQL database. You can also modify additional connection options by selecting Options. Examples of connection options are the database you're connecting to, the connection timeout value, and the network protocol. This article uses the default values for all the options.
Select Connect.
To verify that your SQL database in Fabric connection succeeded, expand and explore the objects within Object Explorer where the server name, the SQL Server version, and the username are displayed. These objects are different depending on the server type.
Troubleshoot connectivity issues
If your browser fails to connect to SQL Database when using Microsoft Entra with MFA, you can navigate to Tools > Options > Azure Services > Azure Cloud, and change the value for either Use system default web browser or Use Web Account Manager. For more information, see Options (Azure Services).
If you experience connection problems with SQL database in Fabric, see Understand network security in Microsoft Fabric
Create a table in the new database
In this section, you create a table in your database.
In the Object Explorer, in the Databases list, right-click on your database, and select New Query:
Paste the following T-SQL code snippet into the query window:
-- 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 ); GOExecute the query by selecting Execute or selecting F5 on your keyboard.
After the query is complete, the new Customers table is displayed in the list of tables in Object Explorer. If the table isn't displayed, right-click the TutorialDB > Tables node in Object Explorer, and then select Refresh.
Insert rows into the new table
Now let's insert some rows into the Customers table that you created. Paste the following T-SQL code snippet into the query window, and then select Execute:
-- 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
Query the table and view the results
The results of a query are visible beneath the query text window. To query the Customers table and view the rows that were inserted, paste the following T-SQL code snippet into the query window, and then select Execute:
-- Select rows from table 'Customers'
SELECT * FROM dbo.Customers;
The query results are displayed under the area where the text was entered.
You can also modify the way results are presented by selecting one of the following options:
- The first button displays the results in Text View, as shown in the image in the next section.
- The middle button displays the results in Grid View, which is the default option.
- The third button lets you save the results to a file whose extension is
.rptby default.
Verify your connection properties by using the query window table
You can find information about the connection properties under the results of your query. After you run the previously mentioned query in the preceding step, review the connection properties at the bottom of the query window.
You can determine which server and database you're connected to, and your username.
You can also view the query duration and the number of rows returned by the previously executed query.
Clean up resources
Remove the sample table we create in this quickstart. Paste the following T-SQL code and Execute:
DROP TABLE dbo.Customers;