Delen via


Scenario's voor Copilot in SQL Server Management Studio

Copilot in SSMS is een geavanceerd AI-hulpprogramma dat is ontworpen om gebruikers van SQL Server Management Studio (SSMS) te helpen bij het beheren en ontwikkelen van SQL-databases. Of u nu een databasebeheerder, databaseontwikkelaar, toepassingsbeheerder, bedrijfsanalist of ergens tussendoor bent, Copilot in SSMS kan u tijd besparen en u helpen efficiënter te worden in uw werkstroom.

Gebruik Copilot in SSMS om vragen te beantwoorden over databases in SQL Server, Azure SQL Database, Azure SQL Managed Instance of SQL Database in Fabric. U kunt ook hulp vragen bij het schrijven van Transact-SQL (T-SQL)-query's met behulp van natuurlijke taal (NL2SQL). Copilot kan ook helpen bij foutberichten, documenteren, uitleggen en oplossen van T-SQL-query's.

Database- en omgevingsverkenning

Stel Copilot een vraag, in welke volgorde dan ook, in de sidecarchat. Voorbeeld:

  • 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?

Ervaring met meerdere beurten

Stel Copilot een reeks vragen, met elke volgende vraag met betrekking tot of in reactie op een eerder antwoord. Voorbeeld:

  • 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.

Multi-turn ervaring met scripting

Wanneer u Copilot een reeks vragen stelt, kunt u het ook stellen om query's te maken die betrekking hebben op het onderwerp.

  • 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

Copilot gebruiken voor hulp bij Transact-SQL

Copilot in SSMS heeft context op basis van uw verbinding met de queryeditor, maar heeft momenteel geen directe toegang tot de query-editor. Als u in een lege editor typt, wordt Copilot-hulp niet aangeroepen. Bovendien kan deze momenteel niet rechtstreeks vanuit de editor worden gelezen (als u iets hebt gemarkeerd) of iets naar de editor kopiëren.

Schrijf Transact-SQL

Copilot kan helpen bij het schrijven van T-SQL met behulp van de prompt die u opgeeft (natuurlijke taal voor T-SQL of NLtoSQL) in de sidecar-chat.

  • 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

Hulp krijgen bij het schrijven van T-SQL-query's in een interactieve meerstapsprocedure.

Naast copilot vragen om hulp bij het schrijven van een query, kunt u vragen om hulp bij het ontwikkelen van query's in de chat, op dezelfde manier als u de query zelf kunt schrijven.

  • 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

Keur de queries goed die Copilot moet uitvoeren

Copilot draait standaard in een alleen-lezen modus. Copilot voert alleen query's uit die gegevens lezen. U kunt de modus echter wijzigen in Lezen/Schrijven met goedkeuring met behulp van de /rwa opdracht in de chat.

  1. Wijzig de modus:

    /rwa

  2. Vraag Copilot om statistieken bij te werken die verouderd zijn:

    Update statistics that are out of date

  3. Geef meer informatie aan Copilot zodat deze de juiste analyse kan uitvoeren:

    List the name of statistics that haven't been updated in over a week that have more than 10% data changed for all tables in the database

  4. Copilot vermeldt de statistieken en vraagt of u ze wilt bijwerken. Als er niet om wordt gevraagd, kunt u de statistieken zelf bijwerken.

  5. Copilot biedt de T-SQL voor de update en biedt de mogelijkheid om Uitvoeren of Annuleren te selecteren.

  6. Selecteer Uitvoeren om statistieken voor Copilot-updates te hebben.

Copilot gebruiken voor databaseontwikkeling

Copilot kan u helpen om snel objecten in uw database te ontwikkelen in de modus Lezen/schrijven . Als u de lees-/schrijfmodus wilt inschakelen, gebruikt u de /rw opdracht.

  1. Wijzig de modus:

    /rw

  2. Vraag Copilot om een set tabellen voor de database te maken:

    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.

  3. Vraag Copilot om indexen te maken:

    Are there any indexes you think I need based on the kinds of queries that we will run to find data?

  4. Vraag Copilot om voorbeeldgegevens te maken:

    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.

Andere voorbeelden

U kunt Copilot elke vraag stellen over SQL of T-SQL schrijven. Controleer altijd scripts voordat ze worden uitgevoerd, omdat AI fouten kan maken.

  • 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.