How to: Use Copilot quick actions for Synapse Data Warehouse

Applies to: Warehouse in Microsoft Fabric

There are two AI-powered quick actions that are currently supported in Copilot for Data Warehouse: Explain and Fix.

Screenshot from the Fabric portal showing the Explain and Fix buttons above a new empty SQL query tab.

Quick actions can accelerate productivity by helping you write and understand queries faster. These buttons are located at the top of the SQL query editor, near the Run button.

  • The Explain quick action will leave a summary at the top of the query and in-line code comments throughout the query to describe what the query is doing.

  • The Fix quick action will fix errors in your query syntax or logic. After running a SQL query and being met with an error, you can fix your queries easily. Copilot will automatically take the SQL error message into context when fixing your query. Copilot will also leave a comment indicating where and how it has edited the T-SQL code.

Copilot leverages information about your warehouse schema, query tab contents, and execution results to give you relevant and useful feedback on your query.

Prerequisites

Get started

Whether you are a beginner or an expert in writing SQL queries, quick actions allow you to understand and navigate the complexities of the SQL language to easily solve issues independently.

Explain

To use Copilot to explain your queries, follow these steps:

  1. Highlight the query that you want Copilot to explain. You can select the whole query or just a part of it. Screenshot from the Fabric portal showing the Explain action and a block of highlighted T-SQL text.

  2. Select the Explain button in the toolbar. Copilot will analyze your query and generate inline comments that explain what your code does. If applicable, Copilot will leave a summary at the top of the query as well. The comments will appear next to the relevant lines of code in your query editor. Screenshot from the Fabric portal showing comments added by Copilot in the T-SQL code.

  3. Review the comments that Copilot generated. You can edit or delete them if you want. You can also undo the changes if you don't like them, or make further edits.

Fix

To get Copilot's help with fixing an error in your query, follow these steps:

  1. Write and run your query as usual. If there are any errors, you will see them in the output pane.

  2. Highlight the query that you want to fix. You can select the whole query or just a part of it.

  3. Select the Fix button in the toolbar. This button will only be enabled after you have run your T-SQL query and it has returned an error. Screenshot from the Fabric portal showing the Fix quick action and a T-SQL query with an error.

  4. Copilot will analyze your query and try to find the best way to fix it. It will also add comments to explain what it fixed and why. Screenshot from the Fabric portal showing comments added by Copilot to the T-SQL query.

  5. Review the changes that Copilot made and select Run to execute the fixed query. You can also undo the changes if you don't like them, or make further edits.