Connect to your SQL database in Microsoft Fabric

Applies to:SQL database in Microsoft Fabric

You can connect to and query your SQL database in Fabric in all the same ways as Azure SQL Database.

Prerequisites

Query editor in the Fabric portal

You can connect to the SQL database using the web-based editor in the Fabric portal.

The web-based editor for SQL database in Fabric provides a foundational object explorer and query execution interface. The integrated Explorer menu lists all database objects.

A new SQL database in Fabric will automatically open into the web editor and an existing database can be opened in the web editor by selecting it in Fabric.

Find SQL connection string

In Microsoft Fabric, the SQL analytics endpoint and SQL database are accessible through a Tabular Data Stream, or TDS endpoint, familiar to all modern web applications that interact with a SQL Server TDS endpoint. This is referred to as the SQL connection string within the Microsoft Fabric user interface.

To find the SQL connection string for your Fabric SQL database:

  • Go to the settings of your SQL database item.
  • Or, in the item list, select the ... menu, select Settings then Connection strings. Fabric provides complete connection strings for providers including ADO.NET, JDBC, ODBC, PHP, and Go.
  • Or, select the Open in button and SQL Server Management Studio. The server connection information is displayed.

To find the SQL connection string for the SQL analytics endpoint of your Fabric SQL database:

  • Go to the settings of your SQL database item, then select SQL endpoint.
  • Or, select the ... menu, then select Copy SQL connection string.

Open in button to connect

You can easy connect to your SQL database with the Open in button in the Fabric portal query editor. Choose SQL Server Management Studio or the mssql extension with Visual Studio Code.

Screenshot from the Fabric portal query editor showing the Open in button for easy connections with SSMS or the mssql extension in VS Code.

Connect with SQL Server Management Studio manually

In SQL Server Management Studio (SSMS):

  1. From your workspace area in the Database workload of Fabric, select the ... next to your SQL database.
  2. Select Settings.
  3. Select Connection strings. Look for the connection string to your SQL database, including the Data Source=. For example, tcp:<servername>.database.fabric.microsoft.com,1433. The Initial Catalog= is the database name.
  4. In SSMS, open a New connection.
  5. Copy and paste the value from Data Source= into the Server name.
  6. Choose Authentication type: Microsoft Entra ID - Universal with MFA support.
  7. Select Options<<.
  8. Copy and paste the value from Initial Catalog= into the Connect to database text box.
  9. Select Connect.
  10. Sign in using Microsoft Entra ID - Universal with MFA support.

Connect with sqlcmd

You can connect to your SQL database in Fabric with sqlcmd, just like any other SQL Database Engine product. Use Microsoft Entra ID authentication with the G option. The Microsoft Entra authentication (-G) require at least version 13.1.

In the following example, replace <server name> with the long string of unique text that represents your SQL database in Fabric.

sqlcmd -S <your_server>.database.fabric.microsoft.com;1433 -G -d <your_database> -i ./script.sql

Connect with bcp utility

You can connect to your SQL database in Fabric with the bcp utility, just like any other SQL Database Engine product. Use Microsoft Entra ID authentication with the -G option.

In the following example, replace <server name> with the long string of unique text that represents your SQL database in Fabric.

bcp bcptest in "c:\temp\sample.dat" -S <your_server>.database.fabric.microsoft.com;1433 -d testdb -G -c