Monday, November 2, 2026

Build the Fence Before Letting in the AI: The Complete sp_Blitz Series

I've spent the last couple of weeks experimenting with Claude Code and SQL Server, building a small application around Brent Ozar's sp_Blitz.

The goal was simple enough: collect SQL Server health check results, compare them over time, and identify what's new, what's fixed, and what hasn't changed.

I wasn't about to hand an AI agent the keys to my SQL Server and hope for the best. So I built a fence first and then I let the AI in, one step at a time.

The experiment turned into a three-part series:

Part 1: Build the Fence

Set up sp_Blitz, create a restricted SQL Server login, establish the AI agent's ground rules, and build the first comparison report. The agent writes the SQL. I run it.

Part 2: Let It Run

Give Claude Code a controlled connection, let it execute the report, and work through the SQL Server permissions needed to make it happen.

Part 3: Trust, but Verify

Clean up the schedule, manage the history, fix misleading comparisons, and use Extended Events to verify what the AI agent actually executed. Then see whether its explanation holds up to scrutiny.

Where I Landed

Three posts, one small application, and quite a few lessons along the way.

And I'm not finished. My next project will take this beyond reporting changes to fully automating the sp_Blitz health check, evaluating prioritized findings, and recommending corrective actions. Users will have the option to review those recommendations and, in some cases, even execute the corrections. But that introduces a whole new set of challenges, particularly around permissions, judgment, and knowing when not to make a change.

Looks like I have another fence to build.

No comments:

Post a Comment