Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

How to use the Microsoft Copilot code completion in Fabric in the SQL database workload

Feedback

In this article

Applies to:SQL database in Microsoft Fabric

Copilot in Fabric in the SQL database workload includes a code completion feature with Copilot.

As you start writing T-SQL code or comments in the editor, Copilot in Fabric SQL database uses your database schema and query tab context to complement the existing IntelliSense with inline code suggestions.

  • The completions can come in varied lengths - sometimes the completion of the current line, and sometimes a whole new block of code.
  • The code completions support all types of T-SQL queries: data definition language (DDL), data query language (DQL), and data manipulation language (DML).
  • You can accept all or part of a suggestion or keep typing to ignore the suggestions. Copilot can also generate alternative suggestions for you to pick.

Prerequisites

  • Verify theShow Copilot completions setting in enabled in your database settings.

    • You can also check the setting's status through the status bar at the bottom of the query editor.

    Screenshot from the Fabric SQL database Query editor, showing the Copilot settings are ready and enabled.

    • If not enabled, then in your databaseSettings, select theCopilot pane. Enable theShow Copilot completions option is enabled.Screenshot from the Fabric SQL database settings, showing the Copilot page and the Show Copilot completions setting.

How can code completions help you?

Code completion enhances your productivity and workflow in Copilot in Fabric SQL database by reducing the cognitive load of writing T-SQL code. It accelerates code writing, prevents syntax errors and typos, and improves code quality. It provides helpful, context-rich suggestions directly within the query editor. Whether you're new or experienced with T-SQL, code completion helps you save time and energy with writing code, and focus on designing, optimizing, and testing your database.

Key capabilities

  • Auto-complete partially written queries: Copilot can provide context-aware SQL code suggestions or completions for your partially written SQL query.
  • Generate suggestions from comments: Guide Copilot using comments that describe your code logic and purpose using natural language. Leave the comment at the beginning of the query and Copilot generates the corresponding query.

Get started

To begin using the Copilot Code Completion feature, follow these steps to enable and utilize its capabilities effectively in the SQL query editor.

  1. Start writing your query in the SQL query editor within the database. As you type, Copilot provides real-time code suggestions and completions of your query by presenting a dimmed ghost text.

    Screenshot from the query editor showing the dimmed text of a Copilot code suggestion.

  2. You can then accept the suggestion with theTab key, or dismiss it. If you don't want to accept an entire suggestion from Copilot, you can use theCtrl+Right keyboard shortcut to accept the next word of a suggestion.

  3. Copilot can provide different suggestions for the same input. You can hover over the suggestion to preview the other options.

    Screenshot from the query editor showing the dimmed text and the selector for multiple selection options.

  4. To help Copilot, understand the query you're writing, you can provide context about what code you expect by leaving a comment with--. For example, you could specify which database object, condition, or methods to use. Copilot can even autocomplete your comment to help you write clear and accurate comments more efficiently.

    Screenshot from the query editor showing a block of code suggestions based on a comment asking for 'list the average temperature of each city'.

Related content


Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?