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.
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.
An interesting suggestion. One problem: when I run this, the result isn’t great.
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.
I wasn’t sure what to do, so I opened the completions panel for Copilot and saw other suggestions.
Let’s try these.
Suggestion 1 looks good. If I change my declaration to be XML, this works (or cast things).
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.
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.
Four and fix aren’t great. They look like repeats. However, six accounts for my declaration.
Does the code work? It does.
I accepted solution 6 to see what happens. The code was added to the query window.
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.
One doesn’t make any sense and doesn’t work. Two and three are nonsense. Four is really interesting, but not useful.
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.