Calling AI from T-SQL: Real-Life Lessons from sp_BlitzCache
Proposed session for SQLBits 2026TL; DR
Brent Ozar cuts through AI hype with real-world lessons from calling LLMs inside sp_BlitzCache. Learn how to pick models, write effective prompts, pass the right context, handle failures, and use AI safely from your own stored procedures.
Session Details
Brent Ozar hates the AI hype just as much as you do, but the thing is, there are useful real-world places where AI's advice is quick, easy, and cheap.
In this session, Brent Ozar shares hard-won, real-world lessons from integrating AI into the widely used open-source tools sp_BlitzCache and sp_BlitzIndex. He'll show how those stored procedures call AI models such as ChatGPT, Google Gemini, Anthropic, and even local models—then turn those responses into actionable performance advice.
You’ll see what worked, what failed, and what surprised him in real production environments. You'll learn how to choose the right model for the job, craft prompts that return useful answers, decide what additional context to send (and what to leave out), and see how to safely integrate AI calls into dynamic SQL. You’ll even learn how to handle API failures, unpredictable responses, and the very human support questions that came up once real DBAs started using AI-assisted performance tuning.
If you’re curious about calling AI from your own stored procedures—but want practical guidance, realistic expectations, and enterprise-ready patterns—this session will give you a clear, usable roadmap.
In this session, Brent Ozar shares hard-won, real-world lessons from integrating AI into the widely used open-source tools sp_BlitzCache and sp_BlitzIndex. He'll show how those stored procedures call AI models such as ChatGPT, Google Gemini, Anthropic, and even local models—then turn those responses into actionable performance advice.
You’ll see what worked, what failed, and what surprised him in real production environments. You'll learn how to choose the right model for the job, craft prompts that return useful answers, decide what additional context to send (and what to leave out), and see how to safely integrate AI calls into dynamic SQL. You’ll even learn how to handle API failures, unpredictable responses, and the very human support questions that came up once real DBAs started using AI-assisted performance tuning.
If you’re curious about calling AI from your own stored procedures—but want practical guidance, realistic expectations, and enterprise-ready patterns—this session will give you a clear, usable roadmap.
3 things you'll get out of this session
Learn how to pick a model and craft a good prompt
Understand what context needs to be sent along with the prompt
Learn how to integrate it all with dynamic SQL
Speakers
Brent Ozar's other proposed sessions for 2026
20 Years of the Cloud: What Changed, What Didn’t, and What’s Next - 2026
AI in Your Career: Sidekick, Hero, or Villain? - 2026
Pokémon Battle, Choose Your Index: You Can’t Have Them All - 2026
The Big Red Button: How to Use sp_Kill - 2026
Watch Brent Tune a Query in SQL Server 2025 - 2026
Brent Ozar's previous sessions
300-Level Guide to Career Internals: Planning Your Career
A roadmap of options for your career.
Fragmentation Explained in 20 Minutes
What do index rebuilds and defrags really do?
Fundamentals of Stored Procedures
How to write stored procedures that have a high likelihood of performing well and are easy to troubleshoot.
300-Level Guide to Career Internals: Planning Your Career
Isn't it awkward when someone asks you, "So, where do you see yourself 5 years from now?" Brent Ozar will share how he analyzed the data job market to build his career path.
500-Level Guide to Career Internals: Building a Brand
If you want to work for yourself, you need to be able to sell yourself. I know, I hate it too - it feels gross when I write it that way. I'm Brent Ozar. You recognize my name, that's why you wanna learn this from me.
Deadlocks: Lets Do One, Understand It, and Fix It
You keep getting warnings and emails about deadlocks, but let's be honest: you're not really sure how they happen or what to do about it. Brent Ozar will show one, use sp_BlitzLock to analyze it, then fix it.
"But It Worked in Development!" 3 Hard Performance Problems
You've been performance tuning queries and indexes for a few years, but lately, you've been running into problems you can't explain. Could it be RESOURCE_SEMAPHORE, THREADPOOL, or lock escalation?
Easy Performance Tuning: an Intro to Wait Statistics
You're a DBA who's struggled with Perfmon metrics and Profiler. You're facing a sea of confusing numbers, and you don't know where to focus first. Microsoft Certified Master Brent Ozar will give you a friendly introduction to wait statistics.
How to Pick SQL Server Hardware
You don't buy a lot of servers, but you're about to deploy SQL Server, and you only get one chance to make it right. Brent Ozar will boil down everything you need to know into just a few simple decisions including SQL Edition, sockets, and RAM.
How the SQL Server Engine Thinks
How does SQL Server build results? We'll role play: Brent Ozar will be an end user sending in queries, and you'll be SQL Server. This session is for people who are comfortable writing queries, but not with indexes, statistics, and sargability.
Watch Brent Tune Queries
Ever wonder how someone else does it? There’s no right way or wrong way, but in this session you can peer over Brent’s shoulder (virtually) while he takes a few Stack Overflow queries and tries various techniques to make them faster.
Virtualization and SAN Basics for DBAs
These two technologies can make a very big – and very bad – difference in how your SQL Server performs. Wouldn’t it be great if you could get the real, honest lowdown from a virtualization administrator, a SAN administrator, and a DBA? Wouldn’t it be even better if one person had done all three, and could give you the pros and cons of each point of view? That person is Brent Ozar, a Microsoft Certified Master who’s been there and done that.
SQL Server Storage - 1,000GB Level
PANIC IN THE DATACENTER! Your databases are approaching - or surpassed - the Terrible Terabyte mark. You're pouring money into the SAN, but your data isn't pouring back out as fast as you want. You're terrified to DBCCs or index maintenance because everything takes forever, and you don't have big maintenance windows.