Introducing Copilot for SQL database in Microsoft Fabric
This last November, we announced the preview of SQL database in Microsoft Fabric. To mark this milestone, we published a blog post providing an in-depth look at the query editor and its core functionalities – Tour the Query Editor in SQL database in Microsoft Fabric. Query Editor is designed to enhance productivity in writing, editing, and executing SQL queries to interact with databases and simplify management tasks like performance optimization.
In this blog we’ll delve into the Copilot integration for Query Editor. We’ll start by getting a high-level understanding of what it is and why does it matter – Think of Copilot for SQL database in Fabric as an AI-powered assistant designed to support you regardless of your SQL expertise or role.
Here’s how Copilot can help:
- Developers can ask natural language questions about their data to generate T-SQL queries or rely on Copilot to complete their code as they type.
- Database administrators can optimize their queries or troubleshoot errors, with Copilot providing solutions and insights directly in response to error messages.
- Citizen developers and business users can quickly grasp complex code with Copilot’s clear and concise inline explanations.
By leveraging your database schema, documentation, and other knowledge sources, Copilot delivers intelligent context-aware answers and assistance. No matter your role or expertise, Copilot makes working with SQL faster, easier, and more intuitive. Rest assured, your business data is secure – Copilot features use Azure OpenAI Service, which is managed and secured by Microsoft. Your data isn’t used to train models and isn’t available to other customers.
Important note: Currently, some regions do not support Copilot for SQL databases in Fabric. However, efforts are underway to make this feature available across all Fabric region availability in January 2025.
Today, we are offering three key functionalities:
1. Chat Pane: Your Collaborative SQL Database Assistant
Open the sidecar chat from the ribbon to interact with Copilot using natural language. Whether you have a question or need a request fulfilled, Copilot provides context-aware responses by leveraging both your database schema and the history of your conversation.
This creates a seamless, multi-turn experience where Copilot acts as a collaborative partner, helping you navigate complex database challenges and offering step-by-step solutions. You can also use the chat pane to learn more about standard SQL, query processing, database management features, and best practices. The Chat pane currently supports two primary skills:
Skill #1 – Natural language to SQL conversion
Copilot can generate DML/DDL/DQL code based on user requests, enabling seamless data querying or object creation.
Sample prompts:
-
- “Create a table called SalesTransactions with columns named CustomerID, ProductID, OrderDate, Quantity”
- “Show customers who placed an order in 2023 and haven’t placed another since.”
- “Rank employees by their sales performance in each region.”
Users can iterate on the generated SQL until they are satisfied with the results, then insert and execute the code directly within the SQL text editor.
To ensure that Copilot generates accurate results, be as specific as possible when crafting your prompts. Clearly describe the information you’re seeking, such as which columns you want to view, the types of aggregations needed, and any filtering criteria.
Skill #2 – Document-Based Insights
Ask Copilot questions about general SQL database capabilities, such as standard SQL language, query processing, and database management features, and copilot will provide an answer based on relevant Microsoft Learn documentation.
Sample prompts:
-
- “What data types are available?”
- “How does my database auto-scale?”
- “How do I query from two or more tables?”
SQL Database in Fabric shares the same engine as Azure SQL Database, so most features are identical. Copilot currently references documentation from Azure SQL Database to provide answers to a wider range of questions. While we’re working to enhance Copilot’s intelligence and reference more knowledge sources, carefully review answers based on Azure SQL Database documentation for any potential differences. For a deeper comparison, read Features comparison: Azure SQL Database and SQL database (preview) Additionally, we are working to expand support for additional database management skills, enabling you to receive self-guided assistance in monitoring your database performance. This will allow you to ask Copilot questions that involve system tables or dynamic management views (DMVs) and help you solve issues independently. For example, you could ask Copilot: “Why is my database slow?” or “How can I tune this high CPU query?”
We’d love to hear which skills would be most valuable to you. Feel free to submit your feedback or upvote suggestions from others. For ideas, you can refer to Microsoft Copilot skills and Azure SQL Database (preview).
–
2. Inline Code Completion: Write Faster, Cleaner SQL
As you begin typing in the SQL text editor, Copilot generates real-time code suggestions to help you complete your code faster. This feature reduces the need to constantly switch between your editor and external resources like documentation or search engines. It also minimizes common syntax errors, leading to cleaner and more reliable code.
Additionally, you can write a comment in plain text to inform Copilot about your request. Based on the comment, Copilot will generate a relevant code suggestion to assist you.
You can enable or disable this feature in the database settings under the ‘Show Copilot completions’ option.
–
3. Quick Actions: Fix and Understand Your Code with Ease
Within the SQL text editor toolbar, you’ll find two quick actions—’Fix query Error’ and ‘Explain query’—that can be used when you select a block of code.
- Fix Code Error: This feature quickly identifies coding errors and suggests fixes, allowing you to maintain your workflow without interruption. It minimizes the risk of introducing new errors by providing fixes that are contextualized to your schema.
- Explain query: This feature provides clear, detailed explanations of complex code, making it an excellent learning tool for both new and experienced SQL users. It also promotes better communication and understanding within teams, enhancing collaboration.
–
Accelerate Your Learning Journey with other Copilot across Microsoft Fabric
Reference the step-by-step tutorial that demonstrates an end-to-end scenario using an SQL database in Fabric, integrating with other Fabric workloads. The tutorial covers creating a database, setting up database objects, exploring autonomous features, and visualizing data.
While Copilot may not be explicitly mentioned in some sections, it’s available in many places to enhance and accelerate these steps.
Here’s how you can leverage Copilot while you follow this tutorial:
- Data Ingestion with Data Factory: Use Copilot for Data Factory in Fabric to use natural language to articulate their requirements for creating solutions using data flows or data pipelines, create summaries, or troubleshoot error.
- Data Analysis in Notebooks: Perform advanced data analysis in notebooks with the help of Copilot for Data Science and Data Engineering in Fabric, which provides insights on data and creates code for visualizations or data transformations.
- Report Creation in Power BI: Create insightful reports using Copilot for Power BI, summarizing or turning your data into charts and actionable insights.
–
Getting started with Copilot for SQL database
Get started with Copilot for SQL database in Fabric today! Learn more about it using the resources below:
- Begin by signing up for a 60-day Fabric free trial.
- Enable features in your tenant settings:
- Explore documentations:
- Visit the Fabric community forums to join discussions and share feedback.
- Contribute and vote for product improvement ideas.