AI and SQL

April 9, 2024

Pinal Dave (@pinaldave), who might always exist in my mind as the person who took me to a KFC in Bengaluru, asks us about how AI has helped our roles as SQL professionals.

Part of me wants to say it hasn’t. To say that what I do in SQL is more complicated than artificial intelligence can handle. I want to point out how I recently asked Bing Copilot a question that I genuinely wanted the answer to, and the answer it gave me was wrong. It suggested that I could use an extension in Azure Data Studio for something… but it was wrong. The reference it gave me to back it up must have misinterpreted a Closed request on uservoice… 

But that wouldn’t quite be right. It wouldn’t tell enough of the story.

When I see the things that Microsoft are bringing out in the “AI plus SQL”, like in the recent discussion between Anna Hoffman and Joe Sack Introducing Copilot in Azure SQL Database (Private Preview) | Data Exposed (two of my favourite people), part of me wonders whether or not it will impact the kind of work that I do for our customers. Tuning, querying, troubleshooting – is this going to make me less relevant? Will it change how I can make a difference, much like the graphic artist who feels threatened by the image-generation tools that are out there, that occasionally put the wrong number of legs on an ice skater (as my wife found out recently).

I can’t say I’ve used much of these SQL tools yet. I do plan to, because I know I’ll be asked about them. I’m starting to use Copilot in Word and Outlook more, but at the moment I find it quicker to write a query in T-SQL than work out the correct prompt and make sure I’m confident of the result. I’m fluent in T-SQL and often see the code before I can put it into English words. Maybe you’d consider me a native T-SQL speaker. It will be there soon though. And for the record, I suspect that creating test cases might be the way this progresses, where the test is easier to validate, and then the code that satisfies the test is automatically valid, almost by definition.

“Intelligent” as a term inside SQL has been around for a while in the form of the Intelligent Query Processing features, but I’m not sure it counts as “artificial intelligence”. I think AI counts as something that has been learned, rather than something which has been measured and chosen because it’s (probably) the best option. Maybe there isn’t a difference between this and AI. If Copilot is recommending indexes because the Query Optimizer considers them as missing indexes, is that any more “learned” than what we get in IQP? But inferring what T-SQL query I want by a prompt in English is more obviously AI. It’s just that I don’t (yet) need something to translate for me from English into my “first language”.

And I shouldn’t ignore the side of AI that I’m definitely using, which is to ask it about the syntax for DATE_BUCKET, or some DAX function. That’s the kind of AI I’m absolutely using.

@robfarley.com@bluesky (previously @rob_farley@twitter)

Leave a Reply

LobsterPot Blogs

Blog posts by Rob Farley and other LobsterPot Solutions team members.

Search