Press "Enter" to skip to content

Curated SQL Posts

HTML Parsing in T-SQL

Louis Davidson goes looking for list items:

From the title of “Favorite String Parsing”, I will say 100% it is using SQL Server 2025’s addition of Regular Expressions. Previously, parsing text in SQL Server was one of my least favorite things to do. Regular expressions will make it just a bit nicer, because it has a lot more power than SUBSTRINGLEFTRIGHT, and CHARINDEX/PATINDEX. All generally “good enough” functions for a lot of the things you need to do, but often woefully inadequate for parsing large amounts of text.

Yeah, T-SQL RegEx is definitely a nicer approach, though HTML doesn’t have to follow the consistency rules of XML due to browsers being very forgiving in their interpretation of the language, so it’s easy to get tangled up trying to parse websites.

Leave a Comment

Named Groups in T-SQL Regular Expressions

Andy Brownsword digs into a nice capability around using regular expressions:

Now that we’re on the cusp of adoption within SQL Server, it’ll be a valuable tool there too. However, after trying it out last week, one omission stood out – one of my favourite features for string parsing: Named Groups.

Where a usual expression can be used to match a string, Named Groups can also be used to extract details from the string. Using an example from Steve’s invitation where a PO number 20260720321433 begins with a year/month and then a number, this could be split with named groups:

Andy mentions the community displeasure for CLR and that displeasure annoys me to no end. I think 90% of the hysteria around CLR in SQL Server was a misunderstanding in terms and unwillingness to learn other programming languages. If you ever catch me in person, I’ll rant about it at length.

Leave a Comment

Tracking Failed SSRS Subscriptions

Svetlana Golovko wants a report of failing reports:

We would like to get notifications if any SSRS report subscriptions fail. This feature was working great until it wasn’t. The scheduled SSRS subscription in the SQL Server Agent job didn’t fail and we were not aware of any failures. In some cases, a partial data driven subscription failed.

Moreover, after some testing we realized that the SQL Server Agent job won’t fail for the Standard subscriptions (that are available in SQL Server Standard Edition) either.

Read on to see what happens when a report subscription delivery fails and how you can get details on the failure.

Leave a Comment

Toggling Light and Dark Modes in Power BI

Elena Drakulevska builds a switch:

We learned in the last post that while dark UI feels sleek, it’s not automatically accessible and it shouldn’t be your default strategy (hello, contrast + glare). In most cases, light mode is the more accessible baseline (just imagine trying to work on a sunny beach or on your balcony with dark mode… nightmare).

But UX is also about choice. Some users love light, some swear by dark. So let’s give them control.

Read on to see how, without sacrificing much accessibility.

Leave a Comment

Copying Data across Tenants with Fabric Data Factory

Ye Xu makes use of the Copy job:

Copy job is the go-to solution in Microsoft Fabric Data Factory for simplified data movement, whether you’re moving data across clouds, from on-premises systems, or between services. With native support for multiple delivery styles, including bulk copy, incremental copy, and change data capture (CDC) replication, Copy job offers the flexibility to handle a wide range of data movement scenarios—all through an intuitive, easy-to-use experience. Learn more in What is Copy job in Data Factory – Microsoft Fabric | Microsoft Learn.

With Copy job, you can also perform cross-tenant data movement between Fabric and other clouds, such as Azure. It also enables cross-tenant data sharing within OneLake, allowing you to copy data across Fabric Lakehouse, Warehouse, and SQL DB in Fabric between tenants with SPN support. This blog provides step-by-step guidance on using Copy job to copy data across different tenants.

Click through for a demonstration, as well as the security permissions that are necessary for this to work.

Leave a Comment

String Parsing in T-SQL

Rob Farley shares some thoughts:

But let’s talk about non-regex methods for parsing strings and the patterns that I use. I find that the biggest issue with most string parsing is complexity. Even something as simple as finding the value between the 2nd and 3rd hyphens can be done in different ways with different levels of complexity, and even if it works, maintaining that code can become really hard.

For example, finding the position of the first hyphen might be as simple as using the CHARINDEX function. Finding the second might involve two CHARINDEX functions, and calling SUBSTRING with parameters that have increasingly nested CHARINDEX calls… well, you can see how the complexity quickly builds

Rob digs into one of my favorite use cases for the APPLY operator: simplifying calculations, or in this case simplifying expression chains. Granted, I have also grown to appreciate the DuckDB solution of allowing for function chaining. The demo examples in that documentation are limited but you can do things like goose_name.lower().replace('goose', 'duck').replace(' ', '') and it will work fine.

Leave a Comment

Regular Expressions in Power BI TMDL View Find and Replace

Jon Vöge performs a search:

For this weeks blog, a quick tip about a feature in Power BI desktop which had flow entirely over my head: You can use RegEx for Find & Replace operations in Power BI Desktop TMDL View!

Yes! You heard that right!

I had no idea, until I caught it in a live demo by Power BI partner director Mohammad Ali at his Power BI Next Step keynote.

Read on to see what you can do with this. The same is possible in other tools like Visual Studio Code and even SQL Server Management Studio, though what specific regular expression capabilities are available and the exact syntax for them will differ based on the product.

Leave a Comment

Checking Direct Lake Model Sources

Nikola Ilic wants to know if Direct Lake is using OneLake or SQL:

In my recent Microsoft Fabric training, I’ve been explaining the difference between the Direct Lake on OneLake and Direct Lake on SQL, as two flavors of Direct Lake semantic models. If you are not sure what I’m talking about, please start by reading this article. The purpose of this post is not to examine the differences between these two versions, but rather to clarify some nuances that might occur. One of the questions I got from participants in the training was:

“How do we KNOW if the Direct Lake semantic model is created as a Direct Lake on OneLake or Direct Lake on SQL model?”

Read on for that answer.

Leave a Comment

Linux Huge Pages and PostgreSQL

Umair Shahid explains the value of huge pages when running PostgreSQL:

Huge pages are a Linux kernel feature that allocates larger memory pages (typically 2 MB or 1 GB instead of the normal 4 KB). PostgreSQL’s shared buffer pool and dynamic shared memory segments are often tens of gigabytes, and using huge pages reduces the number of pages the processor must manage. Fewer page‑table entries mean fewer translation‑lookaside‑buffer (TLB) misses and fewer page table walks, which reduces CPU overhead and improves query throughput and parallel query performance. The PostgreSQL documentation notes that huge pages “reduce overhead … resulting in smaller page tables and less CPU time spent on memory management”

One thing I found interesting here was the advice for PostgreSQL is to disable Transparent Huge Pages whereas in SQL Server on Linux, Microsoft’s recommendation is to keep THP enabled.

Leave a Comment