Edit

Share via


Connect to Fabric Data Warehouse

Applies to: ✅ SQL analytics endpoint and Warehouse in Microsoft Fabric

This tutorial covers connecting tools and applications to your SQL analytics endpoint or Warehouse, or to the snapshot of a Warehouse.

To get started, you need access to a SQL analytics endpoint or a Warehouse within a workspace with Contributor or higher permissions.

Find the warehouse connection string

  1. Open the Settings of your warehouse or SQL analytics endpoint.

  2. In the Settings window, select the SQL endpoint page.

  3. Copy the SQL connection string and use it to connect externally to the item from Power BI desktop, applications, or client tools.

    Screenshot from the Fabric portal of the Settings window, SQL endpoint page.

Connect using SQL Server Management Studio (SSMS)

The following steps detail how to start at the Microsoft Fabric workspace and connect a warehouse to SQL Server Management Studio (SSMS).

  1. When you open SSMS, the Connect to Server window appears. If already open, you can connect manually by selecting Object Explorer > Connect > Database Engine.

    Screenshot showing where to select Database Engine on the Connect menu.

  2. Once the Connect to Server window is open, paste the connection string copied from the previous section of this article into the Server name box. Select Connect and proceed with the appropriate credentials for authentication.

    Screenshot showing the Connect to server window.

  3. Once the connection is established, Object Explorer displays the connected warehouse from the workspace and its respective tables and views, all of which are ready to be queried.

    Screenshot showing where the connected server name appears in the Object Explorer pane.

When connecting via SSMS (or ADS), you see both a SQL analytics endpoint and Warehouse listed as warehouses. Adopt a naming convention that allows you to easily distinguish between the two item types when you work in tools outside of the Microsoft Fabric portal experience. Only SSMS 19 or higher is supported.

Connect using Power BI

A Warehouse or Lakehouse SQL analytics endpoint is a fully supported and native data source within Power BI, and there's no need to use the SQL Connection string. The Data pane exposes all of the warehouses you have access to directly. This allows you to easily find your warehouses by workspace, and:

  1. Select the Warehouse.
  2. Choose entities.
  3. Load Data - choose a data connectivity mode: import or DirectQuery.

For more information, see Create reports on data warehousing in Microsoft Fabric.

Connect using OLE DB

We support connectivity to the Warehouse or SQL analytics endpoint using OLE DB. Make sure you're running the latest Microsoft OLE DB Driver for SQL Server.

Connect using ODBC

Microsoft Fabric supports connectivity to the Warehouse or SQL analytics endpoint using ODBC. Make sure you're running the latest ODBC Driver for SQL Server. Use Microsoft Entra ID authentication. Only ODBC 18 or higher versions are supported.

Connect using Fabric Python Notebook

Fabric Python Notebooks (preview) offer the ability to run T-SQL code with the T-SQL magic command. In the following steps, connect to a warehouse item in Fabric using the %%tsql magic command:

  1. Create a notebook in your workspace with the language set to Python.

  2. In a cell, use the %%tsql magic command. The cell type automatically changes to T-SQL.

    In the following sample, replace <warehouse> with the name of your warehouse item. The -type parameter should be Warehouse.

    %%tsql -artifact <warehouse> -type Warehouse
    

    Then include your T-SQL command. For example, to run a query from a warehouse named Contoso:

    %%tsql -artifact Contoso -type Warehouse
    SELECT * FROM wh.DimDate;
    
  3. You can also bind the results to a dataframe with the -bind argument:

    %%tsql -artifact Contoso -type Warehouse -bind df2
    

For more possibilities to query your data with T-SQL inside Python Notebooks, see Run T-SQL code in Fabric Python notebooks. To see the full syntax, use the %tsql? command. This command displays the help information for the T-SQL magic command, including the available parameters and their descriptions.

Connect using JDBC

Microsoft Fabric also supports connectivity to the Warehouse or SQL analytics endpoint using a Java database connectivity (JDBC) driver.

When establishing connectivity via JDBC, check for the following dependencies:

  1. Add artifacts. Choose Add Artifact and add the following four dependencies, then select Download/Update to load all dependencies. For example:

    Screenshot showing where to select Download/Update.

  2. Select Test connection, and Finish.

    Screenshot of the Dependency Declaration tab.

    <dependency>
       <groupId>com.microsoft.azure</groupId>
       <artifactId>msal4j</artifactId>
       <version>1.13.3</version>
    </dependency>
    
    <dependency>
       <groupId>com.microsoft.sqlserver</groupId>
       <artifactId>mssql-jdbc_auth</artifactId>
       <version>11.2.1.x86</version>
    </dependency>
    
     <dependency>
       <groupId>com.microsoft.sqlserver</groupId>
       <artifactId>mssql-jdbc</artifactId>
       <version>12.1.0.jre11-preview</version>
    </dependency>
    
     <dependency>
       <groupId>com.microsoft.aad</groupId>
       <artifactId>adal</artifactId>
       <version>4.2.2</version>
    </dependency>
    

Connect using dbt

The dbt adapter is a data transformation framework that uses software engineering best practices like testing and version control to reduce code, automate dependency management, and ship more reliable data—all with SQL.

The dbt data platform-specific adapter plugins allow users to connect to the data store of choice. To connect to a warehouse from dbt, use dbt-fabric adapter. Similarly, the Azure Synapse Analytics dedicated SQL pool data source has its own adapter, dbt-synapse.

Both adapters support Microsoft Entra ID authentication and allow developers to use az cli authentication. However, SQL authentication isn't supported for dbt-fabric.

The dbt Fabric DW Adapter uses the pyodbc library to establish connectivity with the Warehouse. The pyodbc library is an ODBC implementation in Python language that uses Python Database API Specification v2.0. The pyodbc library directly passes connection string to the database driver through SQLDriverConnect in the msodbc connection structure to Microsoft Fabric using a TDS (Tabular Data Streaming) proxy service.

For more information, see the following resources:

Connectivity by other means

Any non-Microsoft tool can also use the SQL connection string via ODBC or OLE DB drivers to connect to a Microsoft Fabric Warehouse or SQL analytics endpoint, using Microsoft Entra ID authentication. For more information and sample connection strings, see Microsoft Entra authentication as an alternative to SQL authentication.

Custom applications

In Microsoft Fabric, a Warehouse and a Lakehouse SQL analytics endpoint provide a SQL connection string. Data is accessible from a vast ecosystem of SQL tooling, provided they can authenticate using Microsoft Entra ID. For more information, see Connection libraries for Microsoft SQL Database. For more information and sample connection strings, see Microsoft Entra authentication as an alternative to SQL authentication.