
In a previous post I looked at getting MS Copilot to generate a tSQL code snippet to get a list of countries and their GDP and to insert this into a SQL Server temporary table variable. Here is the post:
The tSQL generated by Copilot is accurate, but the Country and GDP data is coming from some unknown/unspecified location. But what if we know where we /want to get the data from, can we tell Copilot where to get its data In this post I’ll take a look at updating our prompt.
Setting up the Prompt
My test today is to see if I can point Copilot to a specific feed from where to get its data. In this case I’ll try pointing Copilot at the WorldOMeter site where it lists Countries and their GDPs. There is lots else on the site which I’m sure that Copilot can also mine, but the recent list of companies and their GDP is listed here: GDP by Country – Worldometer (worldometers.info)
To set up our prompt to Copilot we’ll need to combine two queries:
- The query to get Copilot to summarize the information on the WorldOMeter site
- The prompt to ask Copilot to set up a tSQL table variable and then populate the table with Country and GDP information
Get Copilot to Summarize the Information on the WorldOMeter Site
We can prompt Copilot to summarize the country GDP information from the WorldOMeter site using:
Get a list of countries and their GDP from https://www.worldometers.info/gdp/gdp-by-country/
The prompt to ask Copilot to set up a tSQL table variable and then populate the table with Country and GDP information
As I explained in my previous article, we can get Copilot to create a table variable and populate it using this prompt:
write a sql server temporary table variable and add in the top ten countries and their gdp. Insert the countries directly and do not assume that a table exists to select from
Combined Solution
We can now combine the two prompts into one prompt that will get Copilot to generate the SQL and populate it with data from the WorldOMeter site:
write a sql server temporary table variable and add in a list of countries and their GDP from https://www.worldometers.info/gdp/gdp-by-country/ Insert the countries directly and do not assume that a table exists to select from
This prompt seems to work well, and Copilot generates things with data from the WorldOMeter site:
DECLARE @GDP TABLE (
Country VARCHAR(100),
GDP MONEY
);
INSERT INTO @GDP (Country, GDP)
VALUES
('United States', 25462700000000),
('China', 17963200000000),
('Japan', 4231140000000),
('Germany', 4072190000000),
('India', 3385090000000),
('United Kingdom', 3070670000000),
('France', 2782910000000),
('Russia', 2240420000000),
('Canada', 2139840000000),
('Italy', 2010430000000);
SELECT * FROM @GDP;
This is quite neat as it means that you can ask Copilot to both generate code as well as to analyze data published on information Web sites and to do it in one go.
Leave a comment