Press "Enter" to skip to content

Curated SQL Posts

Tracking Changes in Power BI Semantic Models

Jens Vestergaard wants to know who moved his cheese:

Semantic models do not have version control. Not really. You can store .pbip files in Git, and Tabular Editor gives you a .bim file you can diff, but neither of those workflows answers the simplest question a team asks after an update cycle: what changed?

I do not mean “which file was touched.” I mean: which measures were modified, which columns were added, which relationships were removed, and what exactly is different in the DAX expression that someone edited last Tuesday. That is the question I kept running into, and the one I built this notebook to answer.

Click through to learn how.

Leave a Comment

Splitting to Table via STRING_SPLIT() and REGEX_SPLIT_TO_TABLE()

Greg Low might have violated Betteridge’s Law of Headlines:

Using T-SQL it’s quite easy to build a table-valued function that can step through a string, character-by-character, and (based on a delimiter) output the delimited strings. The problem is that the performance of these functions is appalling.

When XML support appeared in SQL Server 2005, there were many attempts to create more efficient string-splitting functions. For many strings, these work quite well, but do have a few oddities that you need to cope with. Plus, most have limitations on the strings that you can split.

Ultimately, what was really needed was an efficient and native built-in function.  

Greg points out two mechanisms and contrasts them.

Leave a Comment

Improving Line and Trend Charts in Power BI Reports

Ruben Van de Voorde shares some tips:

Line charts plot a metric along an ordered axis. Usually that axis is time, which is why they’re the first thing most people reach for when the X axis is a date. They show direction, speed and rhythm in a way that tables and bar charts don’t. That ordering is the key requirement: for unordered categories like regions or product types, connecting the points implies a sequence that isn’t there, and a bar chart is the clearer choice.

Power BI makes line charts easy to build: pick a date column, pick a measure, maybe split by a category, and you are done. The result is technically correct, but maybe not as clear as it could be. This article walks through the most common ways a line chart falls short and how to fix them.

There’s a lot of solid advice and good examples in here.

Leave a Comment

“Analyze data with” Updates in Microsoft Fabric

Tzvia Gitlin Troyna shows off some new functionality:

As Microsoft Fabric continues to converge analytics experiences across workloads, one of the most important steps forward is reducing friction in how users move from raw data to insights. With the latest integrations, the Eventhouse Endpoint is now deeply embedded into the “Analyze data with” entry points across LakehouseData Warehouse, and Eventhouse, bringing a consistent, discoverable, and powerful way to analyze data using SQL Endpoint and Notebooks, both new and existing.

Click through to see what this means. This is a preview feature, but it does help tell the story a bit better around Fabric being a coherent entity rather than a bunch of products slapped together.

Leave a Comment

Vertical Partitioning for Performance

Eran Golan splits out a table:

Not long ago, I worked with a customer who was experiencing persistent blocking and occasional deadlocks in one of their core systems. The application itself wasn’t new, but over the years it had grown significantly. New features had been added, more processes were interacting with the database, and naturally the schema had evolved along the way.

One table in particular stood out. It had gradually grown to contain well over a hundred columns. Originally it had been designed to represent a single business entity in one place, which made the model easy to understand and query. But as more attributes were added over time, the table became increasingly wide.

Frankly, based off of Eran’s description, this sounds like a failure in normalizing the table appropriately. Normalization is not just about “There are many of X to one Y, so make two separate tables for X and Y.” In particular, 5th normal form (keys imply join dependencies) tells us that, if we can break out a table X into X1 and X2, and then join X1 and X2 together without losing any information or generating spurious new information, then 5NF requires we break it out. Eran is describing in narrative exactly that concept, though the description of how the customer broke that data out may or may not have satisfied 5NF.

Leave a Comment

PDF Storage via FILESTREAM and FileTable

Garry Bargsley hits us with a blast from the past:

Hello, dear blog reader. Today’s post is coming to you straight from the home office, ready to talk about a topic that comes up more than you’d think: storing PDF documents inside SQL Server.

Whether it’s invoices, reports, scanned forms, or contracts, applications often need somewhere to park files. You could store them on a network share and hope nothing breaks the link, or you could pull them fully into SQL Server where they live alongside your data. In this post, I’m going to walk you through setting up FILESTREAM and FileTable in SQL Server, a feature set that gives you the best of both worlds: transactional integrity from SQL Server and file system performance from NTFS.

I really liked FileTable when it came out, though I don’t believe we ever saw much in the way of additional functionality around FileTable post-2012.

The main challenge I have with FILESTREAM today is that there are too many better places to put documents. There are very few and specific circumstances in which the technology makes sense in a world where block storage in a cloud is cheap and document storage applications are plentiful if you actually need them.

Leave a Comment

Extended Support for SQL Server 2016 Ending

Brent Ozar has a public service announcement:

On July 14, 2026, Microsoft’s extended support ends for SQL Server 2016.

They will offer Extended Security Updates that you can buy for 3 more years, either through Azure or your licensing partner. The price is stunning:

Click through for the prices of extended security updates, as well as some thoughts I generally agree with regarding the importance of staying reasonably up to date on SQL Server versions.

Leave a Comment

Syncing Logins across Failover Groups for Managed Instances

Andy Brownsword gets replicating:

Failover Groups for Managed Instances are a great option to replicate data, but they don’t replicate key instance elements – one of which is logins that live in the master database. If left unchecked, failovers leave systems unable to connect and panic ensues.

To alleviate this we’ll look at a script to synchronise logins and permissions across replicas.

Click through for a link to the script and an explanation of what’s going on with it.

Leave a Comment

Dealing with Bad Parameter Sniffing

Hugo Kornelis has a new video:

The video starts with an explanation of two good features: parameter sniffing and plan caching. But those features can interact in an unwanted way, resulting in erratic bad performance. Now we have what I call “bad parameter sniffing”.

Starting at approximately 8:30, I then describe the three most common root causes for bad parameter sniffing: equality filters on a column with a skewed data distribution; inequality filters with varying selectivity; and optional parameters.

Click through for the rest of the synopsis, as well as the video itself.

Leave a Comment

Cross-Database Ownership Chaining and Why to Avoid It

Fabiano Amorim provides a public service announcement:

A dangerous privilege-escalation path exists in SQL Server when cross-database ownership chaining, system database defaults, and overly permissive permissions are combined. Under these conditions, a low-privilege authenticated user can escalate to sysadmin, gaining full control of the instance. This article walks through how an attacker can abuse these mechanics.

Click through for a detailed explanation of the problem. Then, check out module signing as an alternative that is considerably more secure.

Leave a Comment