Compartir a través de


Escenarios de GitHub Copilot en SQL Server Management Studio (versión preliminar)

Copilot en SSMS es una herramienta de inteligencia artificial avanzada diseñada para ayudar a los usuarios de SQL Server Management Studio (SSMS) a administrar y desarrollar bases de datos SQL. Tanto si es administrador de bases de datos, desarrollador de bases de datos, administrador de aplicaciones, analista de negocios o en algún lugar entre sí, Copilot en SSMS puede ahorrarle tiempo y ayudarle a ser más eficaz en el flujo de trabajo.

Use Copilot en SSMS para responder a preguntas sobre bases de datos en SQL Server, Azure SQL Database, Azure SQL Managed Instance o SQL Database in Fabric. También puede solicitar ayuda para escribir consultas de Transact-SQL (T-SQL) mediante lenguaje natural (NL2SQL). Copilot también puede ayudar con mensajes de error, documentar, explicar y corregir consultas de T-SQL.

Exploración de la base de datos y el entorno

Pregunte a Copilot cualquier pregunta, en cualquier orden, en el chat sidecar. Por ejemplo:

  • What version of SQL is this?
  • List the databases on this instance.
  • List server configuration settings that have been changed from the default in table format with the setting and current value
  • How do I find out who is connected to this database?
  • What is the compatibility mode for the database?
  • hat's the largest table in the database?
  • What columns store email addresses?
  • How many customers do we have and where are they located?
  • Have any SQL Agent jobs have failed in the last week and if so, which ones?

Experiencia de múltiples turnos

Pregunte a Copilot una serie de preguntas, con cada pregunta posterior relacionada con una respuesta anterior o en respuesta a ella. Por ejemplo:

  • What is the compatibility mode for this database?
  • What is the latest compatibility mode available for this version of SQL?
  • How do I change the compatibility mode?
  • How will this change affect query performance?
  • Give me step-by-step instructions for testing a change in compatibility mode for a query without changing the compatibility mode for the entire database.

Experiencia de interacción multiturno con guiones

Al hacerle una serie de preguntas a Copilot, también puede pedirle que cree consultas relacionadas con el tema.

  • What is a database backup?
  • What is the difference between a full and log backup?
  • How do I create a database backup?
  • Does my database need a transaction log backup?
  • How do I create a transaction log backup?
  • Create the script to backup the database
  • How do I automate backups?
  • What should my backup schedule be if the RPO is 30 minutes?
  • Create the script to create SQL Agent jobs for the recommended backup schedule

Uso de Copilot para obtener ayuda con Transact-SQL

Copilot en SSMS dispone de contexto en función de la conexión del editor de consultas, pero actualmente no tiene acceso directo al editor de consultas. En concreto, escribir en un editor en blanco no invoca la asistencia de Copilot. Además, actualmente no puede leer directamente desde el editor (si tiene algo resaltado) o copiar algo en él.

Escribir Transact-SQL

Copilot puede ayudar a escribir T-SQL a partir del texto en lenguaje natural que proporciones (natural language to T-SQL o NLtoSQL) dentro del chat de sidecar.

  • Write a query to return sales information for the last week
  • Write a query to find all the customers who placed orders in July 2024 that totaled more than $1000 and order based on total descending
  • Write the query to change the ReferenceID column in the Tickets table from an INT to a VARCHAR(25)
  • Give me the query to find how much space is being used in tempdb
  • Give me the query to find all open transactions

Obtener ayuda para escribir consultas T-SQL como una experiencia de múltiples turnos

Además de pedir ayuda a Copilot para escribir una consulta, puede solicitar ayuda con el desarrollo de consultas en el chat, de la misma manera que puede escribir la consulta usted mismo.

  • How many customers spent over $100000 in 2023?
  • Give me the query you ran to find that information
  • Take the inner query and change it to select customer ID, customer name, and total spent and order it by total spent descending
  • I forgot I want to include the state where the company is located in the output, please update the query to add that

Uso de Copilot para el desarrollo de bases de datos

Copilot puede ayudarle a desarrollar rápidamente objetos en la base de datos.

  1. Pida a Copilot que cree un conjunto de tablas para la base de datos:

    We're designing a database for a fictional company called Contoso Wireless. They are similar to existing wireless companies in the sense that they sell cell phones, accessories, phone plans, chargers, headsets, and more. Can you suggest some tables that will support my application? This application will support browsing a website, creating orders, paying bills, tracking customer activity, tracking usage, etc. Please provide scripts to create all the tables you see fit and make sure each table has a clustered index for the primary key.
    
  2. Pida a Copilot que cree índices:

    Are there any indexes you think I need based on the kinds of queries that we will run to find data?
    
  3. Pida a Copilot que cree datos de ejemplo:

    We need to generate data for each of the tables. Each table should have 100-1000 rows. The data needs to be realistic (we can't repeat names, products, etc.). Can you help generate scripts for that? It's ok if the scripts are long. Variability in the data is more important than having a short script. For the customers table, use a combination of 50 first names and 50 last names and also use 30 different city/state combinations.
    

Otros ejemplos

Puede preguntar a Copilot cualquier cosa sobre SQL o cómo escribir T-SQL. Revise siempre los scripts antes de la ejecución, ya que la inteligencia artificial puede cometer errores.

  • List the 10 largest tables in the database based on row count in a bulleted list

  • What are the file sizes for this database, their file growth settings, and how much free space do they have?

  • What are the worst performing queries for the last hour?

  • What queries executed most frequently in the last two hours?

  • List all employes and their email address in comma delimited format

  • What are the top 5 products ordered the most in 2024?

  • Calculate the total number of orders for each company in 2023

  • Create a table named Offices in the Sales schema. It should have the columns officeID, office name, address, city, state, zip code, and office manager ID which is foreign key to the People table.