Skip to content

Commit eac9f79

Browse files
committed
Revise GitHub Copilot section in SSMS documentation for clarity and detail, enhancing descriptions of features and usage instructions.
1 parent 574fe1d commit eac9f79

1 file changed

Lines changed: 41 additions & 64 deletions

File tree

  • learn-pr/wwl-data-ai/build-ai-solutions-sql-server/includes

learn-pr/wwl-data-ai/build-ai-solutions-sql-server/includes/2-copilot.md

Lines changed: 41 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
[SQL Server Management Studio (SSMS)](/sql/ssms/sql-server-management-studio-ssms?azure-portal=true) supports two AI-powered coding assistants that help you write, optimize, and troubleshoot [T-SQL](/sql/t-sql/language-reference?azure-portal=true) code. [GitHub Copilot](/ssms/github-copilot/overview?azure-portal=true) provides general coding assistance across multiple languages, while [Copilot](/ssms/copilot/copilot-in-ssms-overview?azure-portal=true) offers database-aware suggestions specific to your connected SQL Server instance.
1+
[SQL Server Management Studio (SSMS)](/sql/ssms/sql-server-management-studio-ssms?azure-portal=true) includes [GitHub Copilot](/ssms/github-copilot/overview?azure-portal=true), an AI-powered assistant that helps you write, optimize, and troubleshoot [T-SQL](/sql/t-sql/language-reference?azure-portal=true) code. GitHub Copilot provides code completions in the query editor when writing T-SQL, and also provides a chat where you can use natural language to get help writing queries, ask questions about your database or environment, and get help with SQL issues. You should always use the latest release of SSMS (currently SSMS 22) as that is the GA release.
22

3-
Both tools use large language models to accelerate database development. GitHub Copilot excels at code completion and pattern recognition across your entire codebase, while Copilot leverages your database schema, indexes, and statistics to provide contextually aware T-SQL assistance.
3+
GitHub Copilot allows you to select a model, and available models vary based on your subscription. GitHub Copilot offers code completion and leverages your connection and database schema to provide context to the model and improve responses.
44

5-
These AI assistants make database development more accessible and improve productivity for both new and experienced developers. Whether you're writing queries, debugging code, or optimizing performance, AI-powered assistance helps you focus on solving business problems rather than remembering syntax.
5+
GitHub Copilot makes database development more accessible and improves productivity for both new and experienced developers. Whether you're writing queries, troubleshooting issues with your code, or optimizing performance, GitHub Copilot helps you focus on solving business problems rather than remembering syntax.
66

77
## Use GitHub Copilot in SSMS
88

9-
[GitHub Copilot in SSMS](/ssms/github-copilot/overview?azure-portal=true) brings AI-powered code completion and generation to your database development workflow. As a general-purpose coding assistant, GitHub Copilot helps you write T-SQL faster by suggesting code as you type and generating entire queries from natural language comments.
9+
[GitHub Copilot in SSMS](/ssms/github-copilot/overview?azure-portal=true) brings AI-powered code completion, generation, and chat to your database development workflow. GitHub Copilot helps you write T-SQL faster by suggesting code as you type, generating entire queries from natural language comments, and providing a chat experience where you can ask questions about your database and get help with SQL issues.
1010

1111
### Understand GitHub Copilot capabilities
1212

@@ -15,23 +15,31 @@ GitHub Copilot provides several features for SQL Server development:
1515
- **Inline code completion:** Real-time suggestions as you write T-SQL code
1616
- **Natural language to code:** Write comments describing your intent, get working queries
1717
- **Multi-line suggestions:** Generate entire query blocks, procedures, or functions
18-
- **Pattern recognition:** Learn from your coding style and common patterns in your workspace
19-
- **Context-aware:** Considers the code you've already written in the current file
20-
- **Multi-language support:** Works with T-SQL, PowerShell, Python, and other languages used in database projects
18+
- **Context aware:** Understands the schema of the database to which you're connected
19+
- **Custom instructions:** Define a custom instruction file and coding style preferences
2120

22-
GitHub Copilot analyzes your current file, open tabs, and workspace to provide relevant suggestions. While it doesn't connect directly to your database, it recognizes T-SQL syntax patterns and common database development practices.
21+
GitHub Copilot also offers these features via its chat:
22+
23+
- **Schema-aware suggestions:** Knows your exact table structures, columns, and data types
24+
- **Query optimization:** Analyzes queries and suggests performance improvements
25+
- **Natural language queries:** Converts questions into T-SQL based on your actual database
26+
- **Explain queries:** Describes what existing queries do in plain language
27+
- **Fix errors:** Provides context-aware suggestions when queries fail
28+
- **Index recommendations:** Suggests indexes based on the missing index suggestions in the DMVs or in a query plan
29+
30+
GitHub Copilot also provides assistance troubleshooting query and database performance, along with answering questions about database maintenance, best practices, database and server configuration, and more.
2331

2432
### Enable GitHub Copilot in SSMS
2533

2634
To use GitHub Copilot in SQL Server Management Studio:
2735

28-
1. Ensure you have [SSMS 19.3](/ssms/download-sql-server-management-studio-ssms?azure-portal=true) or later installed
29-
2. Install the [GitHub Copilot extension](https://docs.github.com/en/copilot/how-tos/set-up/install-copilot-extension) from the Extensions menu
36+
1. Ensure you have [SSMS 22](/ssms/download-sql-server-management-studio-ssms?azure-portal=true) installed
37+
2. Install GitHub Copilot by selecting the **AI Assistance** workload in the [Visual Studio Installer](/ssms/github-copilot/installation-state?azure-portal=true)
3038
3. Sign in with your GitHub account that has an active [GitHub Copilot subscription](https://github.com/features/copilot/plans?azure-portal=true)
31-
4. Configure your preferences in **Tools > Options > GitHub Copilot**
39+
4. Configure your preferences in **Tools > Options > GitHub > Copilot** and **Tools > Options > Text Editor > Inline Suggestions**
3240

3341
> [!NOTE]
34-
> GitHub Copilot requires a paid subscription (Individual, Business, or Enterprise). Some organizations provide GitHub Copilot for their developers as part of their development tools license.
42+
> GitHub Copilot requires a subscription (Individual, Business, or Enterprise). Some organizations provide GitHub Copilot for their developers as part of their development tools license. A GitHub Copilot subscription can also be used with Visual Studio and VS Code.
3543
3644
### Write code with inline suggestions
3745

@@ -40,13 +48,13 @@ GitHub Copilot provides suggestions as you type:
4048
```sql
4149
-- Start typing a query
4250
SELECT c.CustomerName,
43-
-- Copilot suggests: c.Email, c.Phone, c.City
51+
-- GitHub Copilot suggests: c.Email, c.Phone, c.City
4452
-- Press Tab to accept
4553

4654
-- Or write a comment describing what you need:
4755
-- Get total sales by product category for last quarter
4856

49-
-- Copilot generates:
57+
-- GitHub Copilot generates:
5058
SELECT
5159
p.Category,
5260
SUM(od.Quantity * od.UnitPrice) AS TotalSales
@@ -58,7 +66,7 @@ GROUP BY p.Category
5866
ORDER BY TotalSales DESC;
5967
```
6068

61-
The gray ghost text shows Copilot's suggestions. Press **Tab** to accept or **Esc** to dismiss.
69+
The gray ghost text shows GitHub Copilot's suggestions. Press **Tab** to accept or **Esc** to dismiss.
6270

6371
### Generate stored procedures and functions
6472

@@ -96,7 +104,7 @@ GitHub Copilot helps write queries to explore your database structure:
96104
```sql
97105
-- Show all foreign key relationships for Orders table
98106

99-
-- Copilot suggests:
107+
-- GitHub Copilot suggests:
100108
SELECT
101109
fk.name AS ForeignKeyName,
102110
OBJECT_NAME(fk.parent_object_id) AS TableName,
@@ -109,9 +117,9 @@ WHERE OBJECT_NAME(fk.parent_object_id) = 'Orders'
109117
OR OBJECT_NAME(fk.referenced_object_id) = 'Orders';
110118
```
111119

112-
### Learn from your coding patterns
120+
### Apply coding patterns of the current editor
113121

114-
GitHub Copilot adapts to your style over time. If you consistently use specific naming conventions, formatting, or patterns, Copilot incorporates them into suggestions:
122+
GitHub Copilot follows the coding patterns in your current editor. If you use specific naming conventions, formatting, or patterns, GitHub Copilot incorporates them into suggestions:
115123

116124
```sql
117125
-- If you typically write your queries like this:
@@ -122,7 +130,7 @@ SELECT
122130
FROM Customers AS c
123131
WHERE c.IsActive = 1;
124132

125-
-- Copilot learns your style and suggests:
133+
-- GitHub Copilot follows your style and suggests:
126134
SELECT
127135
o.OrderID
128136
,o.OrderDate
@@ -131,7 +139,7 @@ FROM Orders AS o
131139
WHERE o.Status = 'Completed';
132140
```
133141

134-
This personalization makes suggestions feel more natural and reduces the need for manual formatting.
142+
This consistency makes suggestions feel more natural and reduces the need for manual formatting.
135143

136144
### Apply GitHub Copilot best practices
137145

@@ -140,40 +148,20 @@ Maximize GitHub Copilot's effectiveness:
140148
| Practice | Description |
141149
|----------|-------------|
142150
| **Write descriptive comments** | Clear, specific comments produce better code suggestions |
143-
| **Use meaningful names** | Descriptive table and column names help Copilot understand context |
151+
| **Use meaningful names** | Descriptive table and column names help GitHub Copilot understand context |
144152
| **Break down complex tasks** | Write multiple comments for complex procedures rather than one large block |
145153
| **Review all suggestions** | Always validate generated code for correctness and security |
146154
| **Provide examples** | Include sample data or expected output in comments |
147-
| **Keep context nearby** | Open related files or schemas to give Copilot more context |
148-
| **Iterate on suggestions** | If the first suggestion isn't quite right, try rephrasing your comment |
149-
150-
## Use Copilot in SSMS
151-
152-
[Copilot in SSMS](/ssms/copilot/copilot-in-ssms-overview?azure-portal=true) provides database-aware AI assistance that connects directly to your SQL Server instance. Unlike GitHub Copilot, Copilot has access to your database schema, indexes, statistics, and metadata, enabling more contextually accurate T-SQL suggestions.
153-
154-
:::image type="content" source="../media/ssms.png" alt-text="Screenshot showing GitHub Copilot in SQL Server Management Studio with AI-powered code completion." lightbox="../media/ssms.png" border="false":::
155-
156-
### Understand Copilot capabilities
157-
158-
Copilot offers database-specific features:
159-
160-
- **Schema-aware suggestions:** Knows your exact table structures, columns, and data types
161-
- **Query optimization:** Analyzes execution plans and suggests performance improvements
162-
- **Natural language queries:** Converts questions into T-SQL based on your actual database
163-
- **Explain queries:** Describes what existing queries do in plain language
164-
- **Fix errors:** Provides context-aware suggestions when queries fail
165-
- **Index recommendations:** Suggests indexes based on your database statistics
166-
167-
Because Copilot connects to your database, it generates code that works with your specific schema without modification.
155+
| **Iterate on suggestions** | If the first suggestion isn't right, try rephrasing your comment |
168156

169157
### Query with natural language
170158

171159
Ask questions about your data using plain English:
172160

173161
```sql
174-
-- Ask Copilot: "Show customers who placed more than 5 orders last month"
162+
-- Ask GitHub Copilot: "Show customers who placed more than 5 orders last month"
175163

176-
-- Copilot generates (using your actual schema):
164+
-- GitHub Copilot generates (using your actual schema):
177165
SELECT
178166
c.CustomerID,
179167
c.CustomerName,
@@ -188,11 +176,11 @@ HAVING COUNT(o.OrderID) > 5
188176
ORDER BY OrderCount DESC;
189177
```
190178

191-
Copilot knows your exact table and column names, ensuring the query works immediately.
179+
Because GitHub Copilot connects to your database, it generates code that works with your specific schema.
192180

193181
### Optimize query performance
194182

195-
Copilot analyzes queries and suggests improvements:
183+
GitHub Copilot analyzes queries and suggests improvements:
196184

197185
```sql
198186
-- Select a slow query and ask: "How can I make this faster?"
@@ -205,7 +193,7 @@ LEFT JOIN OrderDetails od ON o.OrderID = od.OrderID
205193
WHERE o.OrderDate >= '2024-01-01'
206194
GROUP BY c.CustomerName;
207195

208-
-- Copilot suggests:
196+
-- GitHub Copilot suggests:
209197
-- 1. Change LEFT JOIN to INNER JOIN (WHERE filters out NULLs anyway)
210198
-- 2. Add covering index: CREATE INDEX IX_Orders_Date ON Orders(OrderDate, CustomerID, OrderID)
211199
-- 3. Consider indexed view for frequent aggregations
@@ -222,7 +210,7 @@ OPTION (RECOMPILE);
222210

223211
### Understand and fix errors
224212

225-
When queries fail, Copilot explains the issue and provides fixes:
213+
When queries fail, GitHub Copilot explains the issue and provides fixes:
226214

227215
```sql
228216
-- Query with error:
@@ -231,9 +219,9 @@ FROM Orders;
231219

232220
-- Error: Column 'Orders.CustomerName' is invalid in the select list
233221

234-
-- Ask Copilot: "What's wrong with this query?"
222+
-- Ask GitHub Copilot: "What's wrong with this query?"
235223

236-
-- Copilot explains and fixes:
224+
-- GitHub Copilot explains and fixes:
237225
/*
238226
The error occurs because CustomerName is not in an aggregate function or GROUP BY clause.
239227
When using aggregate functions like SUM(), all non-aggregated columns must be grouped.
@@ -245,19 +233,8 @@ FROM Orders
245233
GROUP BY CustomerName;
246234
```
247235

248-
### Choose the right tool
249-
250-
Both tools offer value for SQL Server development:
251-
252-
| Feature | GitHub Copilot | Copilot |
253-
|---------|----------------|-------------------|
254-
| **Database schema awareness** | No | Yes |
255-
| **Multi-language support** | Yes | T-SQL focus |
256-
| **Query optimization** | Pattern-based | Database-specific |
257-
| **Works outside SSMS** | Yes | No |
258-
| **Requires database connection** | No | Yes |
259-
| **Subscription** | GitHub Copilot | Copilot |
236+
### Get the most from GitHub Copilot
260237

261-
Use **GitHub Copilot** for general T-SQL development, multi-language projects, and code completion across your entire codebase. Use **Copilot** for database-specific tasks where schema awareness, query optimization, and direct database interaction provide better results.
238+
The GitHub Copilot chat window works without a database connection, but it's much more valuable when you have a query editor open and connected to a database. Use GitHub Copilot for general T-SQL development, code completion in the editor, understanding your database and server, query optimization, and more.
262239

263-
Many developers use both: GitHub Copilot for day-to-day coding and Copilot when working with specific database instances. Together, these AI assistants accelerate database development while maintaining code quality and security standards.
240+
Developers can use GitHub Copilot for day-to-day coding and to answer specific database questions, helping accelerate database development while maintaining code quality and leveraging best practices.

0 commit comments

Comments
 (0)