Press "Enter" to skip to content

Curated SQL Posts

The Yin and Yang of Language Models

Erik Darling details a series of problems and somewhat-solutions:

This post is inspired by my BFFL Joe Sack’s wonderful post: Keep Humans in the Circle.

It’s an attempt to detail my progression using LLMs, up through how I’m using them today to build my free SQL Server Monitoring and Query Plan analysis tools.

While these days I do find LLMs (specifically Claude Code) to be wonderful enablers for my ideas, they still require quite a bit of guidance and QA, and they’re quite capable of (and sometimes seemingly eager to) wreck your day.

I did enjoy reading about Erik’s journey, so I figure I’ll share something of my own.

Jonathan Stewart (linking SQL Bites because I’m actively trying to shame him into creating a first video) has gone head-first into Claude Code and has dragged me along kicking and screaming. A lot of what Erik mentions resonates well with me, but there’s something that Jonathan developed that has helped: the Hater persona as an MCP server.

The Hater persona’s job is to critique whatever solution the language model comes up with. Find all of the nitpicks, point out the major gaps in implementation, come up with scenarios in which this just won’t work, that kind of thing. I’ve been Jonathan’s Hater-as-a-Service for years, so naturally, he named the MCP server Kevin. Artificial Kevin can iteratively to come up with the biggest problems, and feed that information back into the main model to fix it up. After several rounds of this, I’ve found that there aren’t nearly as many rough edges as you might find at the start.

Even so, I still stand by the assertion that language models are akin to drunken interns, and the extent to which you trust the output of a language model is on you. But in fairness, hiring the average dev from Fiverr gives you the same experience but a few orders of magnitude slower.

Leave a Comment

Binary Search for Chronological Records in SQL Server

Andy Brownsword performs several probes:

Specifically we’ll use a binary search approach to narrow the search range. We abuse the correlation between the clustering key and timestamp to zero in on the records, using the key for navigation, and the timestamp to guide us.

We’ll start with the first and last records as boundaries, followed by checking the timestamp at the mid-point. Depending on whether the timestamp is before or after our target point in time, the appropriate boundary is moved. This halves the key space, and the search repeats until we’ve narrowed the range sufficiently to scan a very small portion of records.

It’s a neat idea, though do watch for Andy’s warning at the end.

Leave a Comment

SQL Server 2025 and PBKDF2

Rebecca Lewis notes the slowdown:

You upgraded to SQL Server 2025. Your SQL auth logins are slower. This is not a bug. Microsoft did this on purpose — which is actually good news, but if you’re not using connection pooling, it’s not going to feel very good.

Read on for more details, as well as a recommendation for connection pooling. On the whole, this is a very good thing—PBKDF2 is a mature process that we’ve had available to use in applications for 15+ years, and what’s particularly neat about it is that the level of effort scales linearly. As computer hardware becomes more powerful, add more iterations of the hashing algorithm to keep a fairly consistent per-login delay.

Leave a Comment

Managing Non-Deterministic Behavior in Language Models

Alexander Arvidsson sets expectations:

You’ve written a prompt. It works beautifully. You ship it to production.

Three days later, someone reports wildly different answers to identical questions. You run the exact same input and get a different result than yesterday. Your test suite passes locally, fails in CI, passes again on re-run.

Welcome back to non-determinism in Large Language Models.

Click through for some practical tips on how you can reduce non-deterministic behavior, as well as the trade-offs of doing so.

Leave a Comment

A Sparkline-Enabled KPI Card for Power BI

Elena Drakulevska shares a Power BI custom visual:

Sometimes you start experimenting with something small… and suddenly a whole little universe appears.

This happened while I was playing with the idea of a custom KPI card visual in Power BI.

I absolutely love KPI cards, but I’ve never shipped a custom SVG KPI to clients before. Once you do that, they can get a bit… stuck with it.

So I decided to explore a different path.

Following the fantastic tutorial by Phil Seamark, I built my first custom visual!

Click through for the results.

Leave a Comment

An Overview of pgNow

Hamza Sajawal looks at a Redgate product:

pgNow is a lightweight PostgreSQL diagnostic tool developed by Redgate that provides quick visibility into database performance without requiring agents or complex setup. It connects directly to a PostgreSQL instance and delivers real-time insights into query workloads, active sessions, index usage, configuration health, and vacuum activity, helping DBAs quickly identify performance bottlenecks. Because it runs as a simple desktop application, pgNow is particularly useful for quick troubleshooting and point-in-time diagnostics when a full monitoring platform is not available. 

The tool is currently free to use, and its development is actively maintained by Redgate, with potential future enhancements expected as the project evolves. It analyzes workload behavior using PostgreSQL system views and extensions such as pg_stat_activity and pg_stat_statements.

Click through for setup instructions and an overview of what it currently can do.

Leave a Comment

Managing Eventhouses and Environments with MicrosoftFabricMgmt

Rob Sewell continues a series on the MicrosoftFabricMgmt module. First up is a dive into the Kusto world:

Real-Time Intelligence (RTI) is Microsoft Fabric’s answer to streaming data workloads. If you are ingesting telemetry, IoT data, clickstreams, or any high-velocity data that needs querying with low latency, this is the part of Fabric you want. MicrosoftFabricMgmt supports the full set of RTI resources: Eventhouses, KQL Databases, KQL Dashboards, KQL Querysets, and Eventstreams.

Rob then pivots to creating an environment from scratch:

Over the past few posts we have worked through a number of the item choices that you can use in the MicrosoftFabricMgmt module. Today I want to bring it all together into a single, practical script that provisions a complete Fabric environment from scratch.

This is the kind of script I could use when setting up a new project. It is repeatable, idempotent (safe to run multiple times), fully logged, and handles errors gracefully.

Leave a Comment

Rolling Average Calculation via DATE_BUCKET()

Koen Verbeeck writes some code for SQL Server 2022 or later:

In the Microsoft Fabric Warehouse, a new T-SQL function was recently added: the DATE_BUCKET function. With this function, you can group dates into pre-defined buckets. This allows you to easily calculate aggregates that use the GROUP BY clause over these buckets, greatly simplifying the T-SQL statements for analytical use cases.

Click through for a demo. Koen mentions that this is also now available in the Microsoft Fabric Warehouse. Once you know how DATE_BUCKET() works, it’s pretty powerful. But I also think that the function is a bit confusing to use.

Leave a Comment

Finding Power BI Measures without Column Relationships

Zoe Douglas gives a visual cue that not all is well:

Have you ever put a measure on a visual with a column from a table and found it repeated the same value for every row and the total? This indicates there is no relationship for that measure and the column. And that simply may be the case, as in, there is no relationship to create. Let’s look at how we can account for that in a different way, by showing a placeholder value such as ###.

Read on to see how.

Leave a Comment

Migrating SQL Server Service Accounts to gMSA

Deepthi Goguri takes advantage of Group Managed Service Accounts in Windows:

A Service Account is something that applications like the SQL Server, IIS, or scheduled tasks need to run under using Microsoft Active Directory. These are the regular domain user accounts, where the passwords needs to be manually managed and rotated. As these needs to be manually updated, downtime to the services are required if the password needs to be changed. Not only that but syncing these passwords across multiple servers can be an issue. This problem is resolved by using the Standalone Managed Service Account as Windows can manage the password automatically.

Read on to learn more about single MSAs and group MSAs, and some tips and limitations.

Leave a Comment