Tech | Visa | Scholarship/School | Info Place

Can Microsoft Copilot write simple SQL commands for you?

According to major tech companies, generative AI platforms like Microsoft Copilot will make the work lives of people at all levels of business organizations more efficient. But is this just hyperbole, or is there some truth to these claims?

For example, does the free version of Microsoft Copilot available to all Windows users write common SQL queries for you based on commands? This ability is useful for time-constrained, inexperienced employees trying to meet deadlines. Next, we explore what happens when we ask Microsoft Copilot for some SQL help.

Download: TechRepublic Premium’s quick AI glossary

Test Microsoft Copilot’s ability to write simple SQL commands

For our experiment, we started with something basic and simple. Using creative mode, we asked Microsoft Copilot to provide the code needed to create a table named Employee in SQL with four columns: EMP_ID, Name, Salary, Age. AI provides this code:

Name VARCHAR(100),
Salary DECIMAL(10, 2),


You can see the tips and code in Figure A.

Ask Microsoft Copilot how to create a simple SQL table.
Figure A: Ask Microsoft Copilot how to create a simple SQL table.Image: Mark W. Kaelin

While this code may need to be adjusted to your specific needs, overall it is accurate and useful according to Copilot’s requirements.

Also note the explanation provided by Microsoft Copilot; it’s just as important as the code:

“This statement defines EMP_ID as an integer, which is the primary key of the table, Name as a variable string with a maximum length of 100 characters, Salary as a decimal, a total of 10 digits, 2 digits after the decimal point, and Age as an integer. According to you Adjust the data type and size to your specific requirements.”

Continuing the session with Microsoft Copilot, we then ask the AI ​​to generate the code needed to insert new records into the table. The resulting code is as follows:

INSERT INTO Employee (EMP_ID, Name, Salary, Age) VALUES (1, 'John Doe', 55000.00, 30);

You can see the tips and code in Picture B.

Ask Microsoft Copilot how to insert records into a SQL table.
Figure B: Ask Microsoft Copilot how to insert records into a SQL table.Image: Mark W. Kaelin

The VALUES section will need to be modified for your specific needs, but the code and explanations provided by Copilot are accurate and useful. It’s worth noting that once our employees table is complete, we may need to write queries to pull data from the database.

Next, in a meeting with Microsoft Copilot, we asked the AI ​​to generate the necessary code to list employees of a specific age or older in this table. In this case, Microsoft Copilot recommends using this code.

SELECT * FROM Employee WHERE Age >= 30;

You can see the tips and code in Figure C.

Figure C: Asking Microsoft Copilot to select records from a SQL table.Image: Mark W. Kaelin
Figure C: Asking Microsoft Copilot to select records from a SQL table.Image: Mark W. Kaelin

Again, while you may need to adapt the code to your specific needs, this code is accurate and useful for employees who are less familiar with SQL syntax.

So when asked about the right approach, Microsoft Copilot can write basic SQL code for your people. However, whatever answers Copilot generates should always be carefully checked for suitability and accuracy.

Download: Artificial Intelligence vs. Machine Learning Differences and Use Cases in TechRepublic Premium

What have we learned about Microsoft Copilot and SQL code generation?

We can draw the following conclusions from the Microsoft Copilot experiment:

  • Under the right conditions, when asked the right questions, Copilot can provide useful and accurate SQL commands that employees can apply to their work tasks.
  • The free version of Microsoft Copilot captures “knowledge” by modeling data from Bing searches and the Internet. Tutorials that explain basic SQL commands and provide SQL tips are common on the Internet. These two conditions mean that asking Copilot what a SQL command returns is more likely to return a useful answer. However, asking about topics that aren’t popular or haven’t been explored on the internet may not be as successful.
  • Relying on Internet-generated data for business decisions can be a risky activity. The Internet is notorious for inaccurate and misleading information, and in some cases, the answers provided by Microsoft Copilot may be affected by these inaccuracies.
  • Even if the answers provided by Microsoft Copilot are useful, they must always be reviewed and filtered by employees to ensure accuracy and applicability. While generative AI can be a powerful tool, it is rarely trusted to make final decisions or take action on its own.
  • One of the most powerful aspects of Microsoft Copilot sessions is the ability of AI to iterate on answers. In our example, we were able to use Copilot’s previous answers to our questions as the basis for our next question. This feature allows employees to have a conversation with artificial intelligence and then come up with the most accurate and useful answers.
  • Our examples also show that the more detailed the questions submitted to Microsoft Copilot, the more accurate the answers generated. By including variable names, Copilot is able to provide a complete answer rather than just a generic SQL command prompt. The ability to ask detailed questions is the difference between a simple search and a useful Copilot session.
  • Using Microsoft Copilot requires an adjustment in the thinking of employees seeking to use it as a work tool. Copilot is not just another search engine, nor should it be treated that way. Essentially, employees are asking Copilot to read and interpret information available on the Internet for them, and then provide useful, accurate, and actionable answers to their questions. The questions employees ask Copilot are fundamentally different from the questions they ask basic search engines.

Should employees trust Microsoft Copilot to complete their work tasks?

We’ve proven that Microsoft Copilot can be a useful productivity tool for your employees, but only if used correctly. Employees must realize that Copilot, and any other generative AI platform, is not just another search engine. Questions submitted to Copilot must be thoughtful, detailed, and specific. The more detailed the question, the more detailed the answer. Employees must also realize that the first question is often just the basis for a more useful and enlightening conversation with the first officer.

#Microsoft #Copilot #write #simple #SQL #commands

Leave a Reply

Your email address will not be published. Required fields are marked *