How to Write SQL with Copilot in Fabric Warehouse
Copilot in Microsoft Fabric turns a plain-language question into a ready-to-run T-SQL query, right inside the Data Warehouse editor. If you are new to SQL, it is a fast way to reach the query you need; if you already know the language, it speeds up your everyday writing. What follows is a step-by-step guide to writing SQL with Copilot in the Fabric Warehouse, from turning the feature on to validating the result.
Prerequisites
- A paid Fabric capacity (F2 or higher, or P1) assigned to the workspace.
- The Copilot setting enabled in the Fabric admin portal by your tenant admin.
- A Warehouse already created, with at least one table that contains data.
- Permissions to create and run queries in that Warehouse.
Step 1: Enable Copilot in Fabric
The Copilot button only appears when the workspace runs on an F2 (or higher) or P1 capacity and the feature is switched on. In the Fabric admin portal, open Tenant settings and turn on the Copilot options. If your tenant or capacity is outside the US or France, Copilot is disabled by default — in that case, the admin must allow data to be sent to the Azure OpenAI service. Without these two steps, the Copilot button will not be visible in the editor.
Step 2: Open the Warehouse and the Copilot pane
In your workspace, open the Warehouse and click New SQL query to open the editor. On the top toolbar, click the Copilot button to open the chat pane on the right-hand side. This pane is where you type questions in natural language and receive the generated queries.
Step 3: Generate SQL from a question
In the Copilot pane, describe what you need in your own words and, whenever you know them, mention the table and column names. For example, you can type:
Show total sales by country for 2025, ordered from highest to lowest.
Copilot returns a T-SQL query similar to this one, which you can add to the editor with a single click on Insert code:
SELECT
c.country AS pais,
SUM(s.amount) AS total_vendas
FROM sales AS s
JOIN customers AS c ON c.customer_id = s.customer_id
WHERE YEAR(s.order_date) = 2025
GROUP BY c.country
ORDER BY total_vendas DESC;
Always review the table and column names. Copilot relies on the Warehouse schema, but if the question is ambiguous it may assume names that do not exist. The clearer your request, the better the generated query.
Step 4: Use code completion with comments
Besides the pane, Copilot offers code completion as you type in the editor. Start a query and leave a comment beginning with -- that describes your intent; Copilot suggests the rest as dimmed ghost text. Press Tab to accept the suggestion.
-- top 5 products by revenue in 2025
SELECT TOP (5)
p.product_name,
SUM(s.amount) AS receita
As you continue, Copilot completes the FROM, JOIN and GROUP BY clauses for you. Code completion works with DDL, DQL and DML statements, so it also helps you create tables or insert data, not only query it.
Step 5: Review and run the query
Before running, read the query from top to bottom and confirm that the filters and joins make sense. When you are happy with it, click Run (or press F5) to see the results in the grid. If something looks off, make your question more specific in the Copilot pane — for instance, giving the exact table name or the period you want.
Check the result
The result is correct when the grid returns the columns you asked for and the values make sense against what you know about the business. A good check is to compare a total (for example, total sales for the year) with a figure you already know from another report. If the row count looks strange, review the WHERE filters and the JOIN conditions Copilot generated — that is usually where the differences come from.
Conclusion
In just a few steps, you went from a plain-language question to a valid T-SQL query, ready to run in the Fabric Warehouse. A natural next step is to save your most useful queries as views and try more demanding requests, with several joins and aggregations. What will be the first question you ask your data with Copilot?