संपादन करना

के माध्यम से साझा करें


Use Code Completions in SQL Server Management Studio (Preview)

Use GitHub Copilot in SQL Server Management Studio (SSMS) to enhance your Transact-SQL (T-SQL) development with AI assistance. GitHub Copilot helps you be more productive and efficient when writing T-SQL.

In this article, you learn how to use GitHub Copilot Completions, which provide you with context-aware code completions, suggestions, and even entire code snippets. This feature helps reduce the time spent on repetitive tasks and minimizes errors.

For related information about GitHub Copilot Chat, see Use the GitHub Copilot Chat experience in SQL Server Management Studio (Preview).

How Code Completions work

Code Completions for GitHub Copilot in SSMS use advanced machine learning models trained on a vast dataset of publicly available code from GitHub repositories. As you type code, the AI analyzes the context and provides relevant suggestions in real time. You can also receive suggestions by writing a comment in natural language that describes what you want the code to do.

Prerequisites

Code Completions for GitHub Copilot in SSMS supports the T-SQL language.

  1. Install SSMS 22.2 or later with the AI Assistance workload.

  2. Sign in to your GitHub account with Copilot access.

Use GitHub Copilot for free. Sign up and use AI to code faster and more efficiently.

Use GitHub Copilot for code completions and suggestions

As you type comments or T-SQL in the editor, GitHub Copilot provides context-aware code completions and suggestions.

  1. Open SSMS and connect to your database in query editor.

  2. In the editor, enter a comment to see inline code suggestions from GitHub Copilot:

     --list all tables in this database
    
  3. Select enter to see the suggestion.

  4. To accept the suggestion, select Tab. To reject the suggestion, select Esc or continue typing.

Shortcuts and settings

Several keyboard shortcuts are available for completions:

  • To manually trigger a completion, use Alt+. or Alt+,.
  • To cycle through available completions, use Alt+. to move to the next suggestion and Alt+, to move to the previous suggestion.
  • To partially accept a completion word by word, use Ctrl+Right arrow.
  • To partially accept a completion line by line, use Ctrl+Down arrow.

You can customize your completion experience by changing selected settings.

If completions appear too quickly and interrupt your typing, you can adjust the display timing in Tools > Options > All Settings > Text Editor > Code Completions > Preferences. Select Show code completions only after a pause in typing to stop displaying completions while you're typing. This setting adds a debounce delay, so completions don't flash and disappear while you're typing.

By default, each keystroke automatically triggers completions. You can disable automatic completions in Tools > Options > All Settings > Text Editor > Code Completions > General when you set Code Completion Invocation to Manual. After you make this change, you can manually trigger completions using the Alt+, keyboard shortcut.

Completions model

The GPT-4.1 Copilot model for code completions is currently the only available model for GitHub Copilot in SSMS. You can find the setting in Tools > Options > All Settings > Text Editor > Code Completions > General > Copilot Completions Model.

If you're a Copilot Business or Enterprise user, your administrator needs to enable this model for your organization. Your administrator can opt in to editor preview features in the Copilot policy settings on GitHub.com. If you're a Copilot Free user, using this model counts toward your 2,000 free monthly completions.