Last Updated, Apr 13, 2024, 2:39 PM Technology
Can Microsoft Copilot Write Simple SQL Commands for You?
technology


According to the claims made by large technology companies, generative artificial intelligence platforms like Microsoft Copilot will make the working lives of people at all levels of a business organization more productive and efficient. But is that 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 for you on command? That ability would be extremely useful for a time-constrained, less-experienced employee trying to meet a deadline. Below, we explore what happens when we ask Microsoft Copilot for some SQL help.

DOWNLOAD: AI quick glossary from TechRepublic Premium

Testing 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 for the code required to create a table in SQL named 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 prompt and code in Figure A.

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

While this code would likely require tweaking depending on your specific needs, in general, the code was accurate and useful based on what was asked of Copilot.

Note the explanation provided by Microsoft Copilot as well; it is as important as the code:

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

Continuing our session with Microsoft Copilot, we then asked the AI to generate the code necessary 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 prompt and code in Figure B.

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

The VALUES section would need to be modified for your specific needs, but the code and the explanation provided by Copilot were accurate and useful. It’s important to note that once our table of employees is complete, we may be tasked with writing queries to pull data from our database.

Next in our session with Microsoft Copilot, we asked the AI to generate the code necessary to list employees from this table with a certain age or greater. In this case, Microsoft Copilot suggested this code.

SELECT * FROM Employee WHERE Age >= 30;

You can see the prompt 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 adjust the code for 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, whatever answers are generated by Copilot should always be scrutinized for applicability and accuracy.

DOWNLOAD: AI vs machine learning differences 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 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 derives its “knowledge” by modeling data from Bing searches and the internet. Tutorials explaining basic SQL commands and offering SQL tips are common on the internet. Those two conditions mean asking Copilot about SQL commands returns is more likely to return useful answers. However, asking about topics not prevalent or not explored on the internet may not be as successful.
  • Relying on data generated from the internet for business decisions can be a risky activity. The internet is infamous for inaccurate and misleading information, and answers provided by Microsoft Copilot, in certain situations, could be tainted by these inaccuracies.
  • Even if the answers provided by Microsoft Copilot are useful, they still must always be vetted and filtered by employees for accuracy and applicability. While generative AI can be a powerful tool, it should seldom be trusted with making final decisions or acting on its own.
  • One of the most powerful aspects of Microsoft Copilot sessions is the AI’s ability to iterate answers. In our example, we were able to use Copilot’s previous answers to our questions as a foundational basis for our next questions. This capability allows employees to have a conversation with the AI and then build toward the most accurate and useful answer.
  • Our example also shows that the more detailed the question submitted to Microsoft Copilot, the more accurate the generated answer. By including variable names, Copilot was able to provide complete answers and not just general SQL command tips. The ability to formulate detailed questions is what separates a simple search from a useful Copilot session.
  • Using Microsoft Copilot requires an adjustment in thinking by employees seeking to use it as a work tool. Copilot is not just another search engine, and it should not be approached that way. Essentially, employees are asking Copilot to read and interpret information available on the internet for them and then present useful, accurate and viable answers to their questions. The questions employees ask of Copilot will be fundamentally different from the questions they ask of a basic search engine.

Should employees trust Microsoft Copilot for work tasks?

We have proven that Microsoft Copilot can be a useful productivity tool for your employees, but only if it is 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 thought out, 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 foundation that leads to a more useful and enlightening conversation with Copilot.



Source

24World Media does not take any responsibility of the information you see on this page. The content this page contains is from independent third-party content provider. If you have any concerns regarding the content, please free to write us here: contact@24worldmedia.com

Stay Conected