Can Microsoft Copilot write simple SQL commands for you?

Generative AI platforms like Microsoft Copilot will make the work lives of people at all levels of a business organization more productive and efficient, big tech companies say. But is it just hyperbole or do the claims have some merit?

For example, can the free version of Microsoft Copilot, available to all Windows users, write a common SQL query on command? That capability would be extremely useful for a time-poor, less experienced employee trying to meet a deadline. Below, we explore what happens when we ask Microsoft Copilot for help with SQL.

DOWNLOAD: TechRepublic Premium AI Quick Glossary

Testing Microsoft Copilot's ability to write simple SQL commands

For our experiment, we start with something basic and simple. Using Creative mode, we asked Microsoft Copilot for the code needed to create a table in SQL called Employee that included four columns: EMP_ID, Name, Salary, Age. The AI ​​provided this code:
CREATE TABLE Employee (


EMP_ID INT PRIMARY KEY,
Name VARCHAR(100),
Salary DECIMAL(10, 2),
Age INT

);

You can see the message and code at Figure A.

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

While this code will likely require adjustments based on your specific needs, overall the code was accurate and useful based on what was asked of Copilot.

Please also note the explanation provided by Microsoft Copilot; It is as important as the code:

“This statement defines EMP_ID as an integer and the primary key of the table, Name as a variable character string with a maximum length of 100 characters, Salary as a decimal with 10 digits total and 2 digits after the decimal point, and Age as a whole number. Adjust data types and sizes to your specific requirements.”

PEOPLE ALSO LIKE:  Big tech companies insisted 2024 would be the year of the AI ​​PC: analysts disagree

Continuing our session with Microsoft Copilot, we asked the AI ​​to generate the code needed to insert a new record into this table. The resulting code is below:

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

You can see the message and code at Figure B.

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

The VALUES section should be modified for your specific needs, but the code and explanation provided by Copilot was accurate and helpful. It is important to note that once our employee table is complete, we may be tasked with writing queries to extract data from our database.

Next, in our session with Microsoft Copilot, we asked the AI ​​to generate the code needed to list employees in this table of a certain age or older. In this case, Microsoft Copilot suggested this code.

SELECT * FROM Employee WHERE Age >= 30;

You can see the message and code at Figure C.

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

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

So when asked the right way, Microsoft Copilot can write basic SQL code for your employees. However, any response Copilot generates should always be examined for applicability and accuracy.

DOWNLOAD: Differences between AI and machine learning and use cases from TechRepublic Premium

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

We can draw these conclusions from our experiment with Microsoft Copilot:

  • Under the right conditions and when the right questions are asked, Copilot can provide useful and precise SQL commands that employees can apply to their work tasks.
  • The free version of Microsoft Copilot obtains its “knowledge” by modeling data from Bing and Internet searches. Tutorials explaining basic SQL commands and offering SQL tips are common on the Internet. Those two conditions mean that asking Copilot about the results of SQL commands is more likely to return useful answers. However, asking about topics that are not common or not explored on the Internet may not be as successful.
  • Relying on data generated on the Internet to make business decisions can be a risky activity. The Internet is famous for its inaccurate and misleading information, and the answers provided by Microsoft Copilot, in certain situations, could be tainted by these inaccuracies.
  • Even if the answers provided by Microsoft Copilot are useful, employees should always examine and filter them for accuracy and applicability. While generative AI can be a powerful tool, it should rarely be relied on to make final decisions or act on its own.
  • One of the most powerful aspects of Microsoft Copilot sessions is the AI's ability to iterate responses. In our example, we were able to use Copilot's previous answers to our questions as a foundation for our next questions. This capability allows employees to have a conversation with the AI ​​and then develop the most accurate and useful response.
  • Our example also shows that the more detailed the question sent to Microsoft Copilot, the more accurate the response generated. By including variable names, Copilot was able to provide complete answers and not just general advice on SQL commands. The ability to ask detailed questions is what separates a simple search from a useful Copilot session.
  • The use of Microsoft Copilot requires an adjustment in the thinking of employees who seek to use it as a work tool. Copilot is not just another search engine and should not be approached that way. Basically, employees ask Copilot to read and interpret information available on the Internet and then present them with useful, accurate and actionable answers to their questions. The questions employees ask Copilot will be fundamentally different from the questions they ask a basic search engine.
PEOPLE ALSO LIKE:  Windows 11 update brings new tricks to Microsoft Copilot

Should employees rely on Microsoft Copilot for their work tasks?

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

Source link

Leave a Comment