SQL Server Management Studio (SSMS) 中 Copilot 的主要目标是加快 SSMS 工作流中的工作效率,包括编写和编辑 Transact-SQL(T-SQL)。 为了充分利用 SSMS 中的 Copilot,关键在于学习如何与其进行有效协作。 与任何合作伙伴一样,SSMS 中的 Copilot 在给出明确的方向和适当的上下文时表现最佳。 合理使用聊天窗口还能提升您在 SSMS 中使用 Copilot 的体验质量。
聊天窗口
聊天窗口的图标和功能详细记录在SQL Server Management Studio 中用于 Copilot 的聊天窗口,但使用提示时还有其他需要注意的事项。
主要是不要将聊天窗口视为结果窗口。 当你询问有关架构或数据的 Copilot 问题时,它可能会直接执行查询以在聊天窗口中返回信息。 SSMS 中的 Copilot 不会确定查询在执行之前返回的行数,如果查询返回 1,000 行,它将尝试在聊天中显示该信息。 大型结果集在聊天窗口中不容易读取,且无法处理。
要求 SSMS 中的 Copilot 编写查询以返回信息通常是首选的,并在 SSMS 中创建与 Copilot 更好的交互和体验。
一致性
Copilot 用户之间的常见挫折感是响应不一致。 AI 响应可能不一致,因为它们是概率生成的,而不是确定性的。 这意味着,即使被问到相同的问题,模型可能会根据上下文、配置或内部随机因素的细微变化,选择一种不同但仍然合理的词汇或句子结构。 此外,AI 模型权衡了对提示的许多潜在解释,因此措辞或计时方面的小变化可能会导致不同的结果。 这种可变性是 AI 如此灵活和强大的一部分,但如果未以最佳方式构造提示,也可能导致不可预知的结果。
写作提示
使用 AI 固有的是编写提交提示,就像性能优化一样,它是一种艺术和科学。 无需成为提示工程师才能编写良好的提示。 但是,在使用 AI 时,需要了解一般准则。
例如,如果问 Find the hottest tables in the database
,SSMS 中的 Copilot 可能不明白,在此提示的上下文中,最热的表是最繁忙或最活跃的表。 相反,请尝试 List the top 10 tables in the database that have the most reads
。
一般的提示写作建议包括:
建议 | 详细信息 |
---|---|
使用自然语言 | 无需使用专用词汇,但尽量避免非正式短语、俚语和行话。 |
明确且具体 | 提供足够的细节,以便科皮洛特清楚地知道你要问什么。 |
提供上下文 | SSMS 中的 Copilot 具有基于查询编辑器连接的数据库上下文,但可以提供额外的上下文,例如时间范围或特定的数据库对象。 |
使用示例 | 基于以前的响应(如 Modify the last query to order the results by CustomerID )。 |
定义输出格式 | Copilot 可以文本、表或列表格式提供信息。 它为你选择,但你可以专门要求以所需的格式返回信息。 |
示例提示:
建议 | 避免 | 试用 |
---|---|---|
使用自然语言 | Yo cook me up something cool for grabbing sales data |
Write a SQL query that selects the top 10 most recent orders from the Sales.Orders table |
明确且具体 | Okay, so I've got this thing where I need to maybe get some kind of report or output or whatever for yesterday's stuff but like only for users that are new but not too new, if that makes sense |
Write a query to return users who registered yesterday and have not yet made a purchase |
提供上下文 | List western schools with no language reqs |
List schools in the US-West geo that have a lang_req value of 0 |
使用示例 | Write a query to get recent customer info |
Write a query to get customer ID, name, and total number of orders for the last 10 business days ordered by total desc |
定义输出格式 | Give me hospital locations and size with the busiest emergency rooms |
List the hospitals with the busiest emergency rooms in table format and include city state and size |