Press "Enter" to skip to content

Curated SQL Posts

Dockerizing Shiny and RMarkdown Apps

Thomas Williams builds a container image:

Running R Markdown via Docker is a big help with deploying those analysis and reports for others to use.

While there are alternatives for deploying R Markdown — the most popular being Shiny Server — they add the hassle of matching R and package versions to the machine where the code was developed, may require IT help, and mean sharing disk, CPU, and memory with other apps on the same server. And there’s also licensing requirements & limitations for the free version of Shiny Server.

R Markdown on Docker avoids some of these issues; a single Docker container = a single app.

Click through for a simple RMarkdown file and Dockerfile.

Leave a Comment

Thoughts on Database Keys and Constraints

Lee Asher digs into keys:

Keys come in two basic flavors: natural and surrogate. Natural keys, as their name suggests, are values that occur naturally in the data. They have real-world or business meaning: an email address, the street address of a building, the serial number of an inventory item, etc. In contrast, a surrogate key (sometimes called a synthetic key) is a value added to each row upon creation. A surrogate exists only within the confines of the database; it has no meaning outside of it.

A natural key often contains two or more columns. For instance, the key for a table of vehicle types might include the make, model, year, and trim level, all four columns of which must be combined to create the value that uniquely identifies each row. Surrogate keys are always a single column, though the value of each key may be anything you choose – as long as each value is distinct from all others.

One thing I would very strongly note here is that surrogate keys are a physical data model concept. I’m a firm believer that you almost always should have a surrogate key, but there must be a natural key, even if you don’t put an actual constraint on it. Though I do recommend having a unique key constraint on the natural key as well as a primary key constraint on the surrogate key.

Leave a Comment

SESSION_CONTEXT and Parallelism Bug in SQL Server

Rebecca Lewis lays out the consequences of an existing bug:

If you use SESSION_CONTEXT() in any query that can run with parallelism, you may be getting wrong results right now and not know it. This is not new. It has been a documented known issue since January 2022. It shipped unfixed in SQL Server 2019, 2022, and 2025 — and as of 2025 CU2 (February 12, 2026), it is still not resolved.

This is easy to miss. It’s buried in the Known Issues section of CU release notes, and the symptoms — wrong results or dump files — do not obviously point back to SESSION_CONTEXT.

Read on to learn more about the issue, the current workaround, and how you can discern whether you are experiencing the issue today.

Leave a Comment

DevOps in Microsoft Fabric

Hamish Watson lays out what DevOps means in the context of Microsoft Fabric:

Microsoft Fabric (not to be confused with the more general term “fabric” in DevOps) is an integrated data and analytics platform designed for modern data-driven workloads, such as data engineering, business intelligence, and machine learning. With the introduction of Git integration in Microsoft Fabric, DevOps practices are becoming more accessible in the platform, allowing teams to implement collaborative, automated workflows that are common in DevOps environments.

Read on for some of the high-level concepts of what we do with DevOps and how they apply directly to Microsoft Fabric workspaces.

Leave a Comment

Query Tuning and Premature Optimization

Denny Cherry shares some advice:

This runs about as inconsistently as you would expect, given that it’s the same plan every time, no matter what values are being passed in. Getting this to perform better and consistanly requires some dynamic SQL changes that look similar to the following.

Denny’s scenario is a very common one: as developers, we don’t know which access paths users will take, so we try to develop generic solutions that can cover a wide variety of scenarios. In practice, users land on a certain set of access patterns, and now we have actual queries we can ensure work as well as possible. Except for the parts where we painted ourselves into a corner with the original generic design. But hey, that’s what the imagined rebuild that will never happen can solve.

Leave a Comment

Fast Failover in SQL Server 2025

John Deardurff lays out some changes in SQL Server 2025:

A client requested a presentation discussing key improvements to Always On Availability Group fast failover in SQL Server 2025. I decided that a summary would be appropriate for a blog post. So, here I discuss Enhanced Telemetry, Persistent Health, and Intelligent Fast Failover 

John has a very positive take on fast failover. I haven’t tried any of this functionality, but some of this does sound promising.

Leave a Comment

Implementing Shamir’s Secret Sharing in SQL Server

Sebastiao Pereira implements an algorithm:

Shamir’s Secret Sharing is a cryptographic algorithm that allows a secret to be split into multiple components and shared among a group in such a way that the secret can only be revealed if a minimum number of components are combined. Is it possible to have this algorithm implemented in SQL Server without using external tools?

Click through for a T-SQL implementation, as well as one using CLR.

Leave a Comment

Updates for sp_Check Tooling

Jeff Iannucci announces some updates:

It’s been a while since we have updated some of these tools, so we have reviewed a lot of outstanding issues. We’ve also been working on pending enhancements, and now have updates for each of the tools. Moreover, there are more updates on the way soon, as we are planning for a more frequent cadence of updates.

Also, I’ll let you in on a little secret: there are more sp_Check tools on the way. We have a few additional stored procedures we have been testing internally that should be ready for public release in the coming months. We’re really excited not just for the new tools, but also for the future feature updates to the current tools.

Click through for a list of tool updates and the GitHub repo where you can find them all.

Leave a Comment

Evaluating Power Query Programmatically in Microsoft Fabric

Mihir Wagle announces a new preview capability:

Power Query has long been at the center of data preparation across Microsoft products—from Excel and Power BI to Dataflows and Fabric. We’re introducing a major evolution: the ability to execute Power Query programmatically through a public API.

This capability turns Power Query into a programmable data transformation engine that can be invoked on demand through a REST API from notebooks, pipelines, and applications. Whether you’re orchestrating data pipelines, building custom data apps, or integrating Power Query into larger workflows, this API unlocks new flexibility and automation.

Click through for an overview of what’s available.

Leave a Comment