Query your SQL database in Fabric
Applies to: ✅ SQL database in Microsoft Fabric
You can query Fabric SQL database just like any other SQL Server database, using SQL Server Management Studio or the mssql extension with Visual Studio Code. Fabric SQL database also includes a lightweight, browser-based query editor that we use here.
Prerequisites
- You need an existing Fabric capacity. If you don't, start a Fabric trial.
- Make sure that you Enable SQL database in Fabric using Admin Portal tenant settings.
- Create a new workspace or use an existing Fabric workspace.
- Create a new SQL database or use an existing SQL database.
Get a quick look at the data
For lightweight queries where you just want to see the structure of a table, the type of data in the table or even what columns the table has, just select on table's name in the Object Explorer. The top 1,000 rows will automatically be returned.
If you want to write a new query with T-SQL, select the New Query button from the toolbar of the query editor.
Tip
To get a head start on the basic structure of a query, select the ...
on the table name, and select SELECT TOP 1000 rows from the menu.
Or, create a new query using the New SQL query dropdown list, then create T-SQL scripts with code templates that populate in your SQL query window.
Ask Copilot to write a query
Copilot can also be used to write a query, and will translate natural language prompts to T-SQL.
Start with a database with some data. For example, try the AdventureWorks sample data.
Select New Query in the ribbon.
Type the following text as a T-SQL comment, then press the tab key:
--I need to query order history, by count and value, grouped by customer company name
You should see a suggestion like this:
Press the tab key to accept the suggested T-SQL code.
Review the query.
Select Run from the toolbar of the query window and review the results.
For more on query capabilities with the SQL database query editor in the Fabric portal, see Query with the SQL query editor.