Blog Post

ADS Copilot Experiments with XML

,

I sent some code to a customer recently to help them decrypt some stored procedures. I sent a quick and dirty set of code, noting at the bottom that the results were in XML and needed to be extracted.

The customer wrote back that my code produced XML and the procedure code had to be copied and pasted into SSMS to create a decrypted procedure.

1f926-2642

Before I spent time on this, I decided that I should play with Copilot here. This is the perfect place and it’s what I’d hope at some point if I sent that code, the other person would use some sort of AI to help them fix things.

Maybe not, but here’s what happened.

This is part of a series of experiments with the ChatGPT and other AI systems. Lots of Copilot lately.

Asking for Help

I could look up the syntax for working with XML, but what about Copilot? Let’s see what happened.

2023-08-03 15_37_47-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

An interesting suggestion. One problem: when I run this, the result isn’t great.

2023-08-03 15_38_41-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

If I cast this as XML, or declare it, things work. At least, they don’t produce errors. But they don’t do what I wanted.

2023-08-03 15_39_52-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

I wasn’t sure what to do, so I opened the completions panel for Copilot and saw other suggestions.

2023-08-03 15_40_47-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

Let’s try these.

Suggestion 1 looks good. If I change my declaration to be XML, this works (or cast things).

2023-08-03 15_41_51-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

Some points for Copilot here, and I’d hope a junior would get to change the declaration or ask how to convert the variable to XML. 

Suggestion two doesn’t work.

2023-08-03 15_43_57-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

Suggestion three looks like a copy paste from a forum somewhere. However, the code works. I don’t know how this gets into the suggestions, but I am interested to know what’s happening here.

2023-08-03 15_45_03-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

Four and fix aren’t great. They look like repeats. However, six accounts for my declaration.

2023-08-03 15_46_25-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

Does the code work? It does.

2023-08-03 15_46_46-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

I accepted solution 6 to see what happens. The code was added to the query window.

A Repeat

I’ve given feedback, so let’s try again. I went back to the prompt and got the same suggestion again, however when I opened the panel, I saw different items.

2023-08-03 15_50_38-● SQLQuery_1 - Aristotle_SQL2022.sandbox (Integrated) - VCS_Primer-1 - Azure Dat

One doesn’t make any sense and doesn’t work. Two and three are nonsense. Four is really interesting, but not useful.

2023-08-03 15_52_17-GitHub Copilot - VCS_Primer-1 - Azure Data Studio

I don’t think Copilot learned anything, and I’m not even sure it is all that well trained. I don’t know if it doesn’t recognize it’s in a database editor or what. The type of language for the ADS file is SQL, so I don’t know what X# and Java are added.

I’m out of patience today. I know how to do this, so I’ll just write the code.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating