T-SQL Notebooks in Fabric – Run Queries, Visualize Data & Save Views
Microsoft Fabric now supports T-SQL Notebooks — a powerful, interactive workspace for data engineers, SQL developers, and analysts to write, execute, and visualize T-SQL code with documentation and rich outputs.
๐ Key Features of T-SQL Notebooks
- Write and run T-SQL code directly in notebook cells
- Connect to Warehouses or SQL analytics endpoints
- Visualize results using built-in charts and column profiling
- Save SQL queries as Views
- Supports cross-warehouse querying with 3-part naming
- Schedule notebooks and use them in pipelines
๐งฑ Step 1: Add Warehouse as Data Source
- Click
+ Data sources
in the notebook toolbar - Select your desired Warehouse or SQL analytics endpoint
- Set one as the Primary source
๐งช Example Queries
-- Query top records from a table
SELECT TOP 5 * FROM TechDWH.dbo.Customers;
๐ก Code Templates
Right-click a table in Object Explorer to generate SQL templates:
- SELECT Top 100
- Create Table
- Drop Table
- CTAS (Create Table As Select)
๐พ Save Query as View
Write your query and highlight it, then click “Save as View” in the toolbar:
SELECT * FROM TechDWH.dbo.Orders
WHERE OrderAmount > 1000;
๐ Cross-Warehouse Queries
SELECT * FROM SalesDW.dbo.SalesCustomer;
Use three-part naming convention: Database.Schema.Table
๐ Visualizing Query Results
- After query execution, go to the Inspect tab
- Explore data distribution and column stats
- Switch to charts (bar, pie, etc.) for quick insights
SELECT TOP 100 CustomerID, FirstName, LastName, Country FROM TechDWH.dbo.Customers;