Press "Enter" to skip to content

Curated SQL Posts

Vector Chunking and SQL Server 2025

Greg Low breaks down a document:

If you’ve started to work with vector databases and looked at using text embeddings for AI search, you might have come across the term chunking and wondered what it relates to. In this article, I’ll explain the concept in general – and then show how it works in SQL Server 2025.

Read on for that explanation. Greg also includes a quick example of how this looks in SQL Server 2025 when passing text data through an embedding model.

Leave a Comment

Avoid JOIN USING in SQL Scripts

Lukas Eder covers an esoteric bit of syntax:

Some SQL operators are as esoteric as they’re powerful. One of the oldest operator that you’ve likely hardly ever used in real world applications is NATURAL JOIN which is the default in relational algebra. We’ve covered a funky use-case for NATURAL JOIN earlier on this blog.

Click through for a similar example using JOIN USING. It’s best to be specific in your SQL queries, at least the permanent ones that you add to scripts you expect to re-run in the future or make part of applications.

Leave a Comment

Filtering DAX Measures through Slicers

Marco Russo and Alberto Ferrari provide a deeper answer:

A very common request by Power BI newbies is, “How can I use a slicer to filter a measure rather than a regular model column?” The most common answer to this question is, “You cannot filter a measure through a slicer”. The answer is entirely correct because there is no such thing as “filtering a measure”. However, elaborating on the why gives us a good way to explain not only what is wrong with the question, but also how to further reason about the requirements needed to obtain a working solution.

This blog post is an example of how challenging it can be to answer a beginner’s question, where the immediate answer is “No, you can’t do that” but the underlying problem is solvable.

Leave a Comment

Moving System Databases in SQL Server

Rich Benner hires some movers:

As consultants, we often see system databases existing on the C drive on SQL Servers. There are some issues with this setup, and the biggest is: if one of your system databases grows and fills your C drive, you will likely crash the OS. If that happens, we’re in big trouble. Therefore, moving system databases becomes a necessary operation at times.

This is such a common issue because the default locations are set to C for these databases and that’s where they end up on fresh installs 99% of the time. Don’t worry! If you’re in this situation you’re not alone.

Click through for a query that shows which databases are on which drive and how to migrate databases post-install.

Leave a Comment

Risks of Using PostgreSQL as a Job Queue

Richard Yen explains why it’s not the best tool for the job:

At small scale, using Postgres as a job queue is totally fine, and I’d even say it’s the right call. Fewer moving parts, one less system to manage, ACID guarantees on your jobs. What’s not to love?

The problem is that “small scale” has a ceiling, and the ceiling is lower than most people expect. When you’ve got thousands of concurrent workers hammering a jobs table with SELECT ... FOR UPDATE SKIP LOCKED, things start to behave in ways that aren’t obvious from the application layer. CPU usage creeps up. Also vacuum sometimes can’t keep up. Finally, in the wait event stats, you start seeing ominous entries like LWLock:MultiXactSLRU stacking up across many backends.

This pattern has tripped up teams more than a few times, and it usually plays out the same way: everything works fine in dev and staging, then goes off a cliff in production once the concurrency gets real. So let’s dig into why this happens, and what the alternatives look like.

Click through for more information. It’s the same on the SQL Server side of the house: once you hit a concurrency threshold, performance drops off of a cliff.

Leave a Comment

A Primer on Group Managed Service Accounts

Randy Knight shows off a useful feature in Windows:

Service account management is one of the quietest ways a SQL Server estate goes wrong. Passwords get set once during install, written down somewhere (or worse, not written down), and then never rotated. The DBA who built the environment leaves. A security audit shows up. Suddenly you’re staring at a hundred service account passwords nobody remembers, and the prospect of changing them all on a maintenance window nobody wants to schedule. Group Managed Service Accounts (gMSAs) solve this.

They’ve been a fully supported option for SQL Server since 2014, they work with Failover Cluster Instances and Availability Groups, and Active Directory rotates the passwords for you on a schedule you control. We use them by default on every new SQL Server build at SSG.

And yet, in a decade of Health Checks, we still rarely see them deployed. The most common reasons we hear: “I tried it once and SPNs broke,” or, “I wasn’t sure it would work with our AG.” Both are addressable. Here’s what you need to know to deploy gMSAs successfully.

gMSAs are very useful at providing a managed identity for on-premises solutions. You don’t need to save passwords anywhere but still have full control over who’s allowed to access a given resource.

Leave a Comment

April Updates for Straight Path Solutions sp_Check Procedures

Jeff Iannucci shares some updates:

We also have been working on the content pages referenced by the URLs in the stored procedures. We’ve been going through them all to make sure the content was more helpful. Lots of the previous content pages have had simple sentences that weren’t very descriptive, so we’ve been filling those out to provide more explanations.

This month the updates are mostly corrections, although there were additional checks added to sp_CheckBackup and sp_CheckTempdb.

Click through for the changelogs and links to the procedures.

Leave a Comment

PostgreSQL and Variables

Shaun Thomas shows off some functionality:

There’s been a kind of persistent myth regarding Postgres since I first started using it seriously over 20 years ago: “Postgres doesn’t support user variables.” This hasn’t really been true since version 8.0 way back in 2005. Part of this stems from the fact it doesn’t do things the same way as other common database engines.

Why don’t we spend a little time exploring the functionality that time forgot?

Reading through the post, I’m pretty happy with the way MySQL and SQL Server do it, even if SQL Server’s variables are batch-level and can be annoying if you want to maintain variable state across batches. In that case, you’d typically use a user-defined table type or temp table to store the values and re-instate them in the next batch.

Leave a Comment

Connecting Semantic Models to Data Sources via Binding Hints

Chris Webb shares a note:

Did you know that you can configure your Power BI semantic model so that it automatically binds to a data source connection when you publish?

To illustrate how to do this, I created an Import mode Power BI semantic model in Power BI Desktop connected to the Products table in the ContosoSales sample database in the Azure Data Explorer help cluster. Anyone can connect to this source, you just need a Microsoft Account to authenticate.

Click through for the code and some additional tips.

Leave a Comment

Recommendations on When to Use CLR

Greg Low shares some thoughts:

I’ve recently been talking to clients about SQL CLR objects. When these were first introduced in SQL Server 2005, many of us had high hopes for them. SQL Server has never been great in regard to extensibility and this provided some way to extend the product.

Nowadays, I avoid SQL CLR. And that’s a real pity. But it’s no longer supported in Azure SQL Database, apart from the system CLR objects of geometry, geography, and hierarchyid. (Note: I’m also not a fan of hierarchyid). I need to use extensibility methods that are available in the different environments that I work in, and Azure SQL Database is one of those. The same applies to Fabric SQL Database.

But for people who don’t use Azure SQL Database or Fabric SQL Database, Greg does share some thoughts below the fold.

Leave a Comment