Press "Enter" to skip to content

Curated SQL Posts

Adding Commas to Numeric Output in SQL Server

Andy Yun is speaking my language:

One thing that’s always driven me crazy is when I have large numbers in my resultsets and the lack of commas for readability. For a lot of different things I do, the more commas a number has, the more attention I want to give to a given value.

Andy shows examples of formatting to two and zero spots after the decimal, respectively. In a talk I give on analyzing business data with T-SQL, I also demonstrate how to show currency-based results:

FORMAT(SUM(o.Quantity * sih.LastCostPrice), N'$0,###.##') AS TotalCost

This starts each cost record with a dollar sign, ensures you have commas in the thousands spots, and have a two-digit decimal value. That would return back a result like $31,409,113.00, which is a lot easier to read than 31409113.

Leave a Comment

Linux and NUMA

Chris Travers provides an overview of NUMA:

This entry in the series focuses on the low-level hows and whys of Non-Uniform Memory Access so that it is possible to understand the solutions and recommendations later with a focus on conceptual details.  Unfortunately in many details this requires focusing on technical details as often the concepts without the details are confusing at best.

Read on for a quick history of NUMA and what options are available in the Linux kernel.

Leave a Comment

OneLake Security and the Fabric SQL Analytics Endpoint

Freddy Santos takes us through the latest with respect to security in OneLake:

OneLake Security centralizes fine-grained data access for Microsoft Fabric data items and enforces it consistently across engines.
Currently in Preview and opt-in per item, it lets you define roles over tables or folders and optionally add Row-Level Security (RLS) and Column-Level Security (CLS) policies. These definitions govern what users can see across Fabric experiences.

Read on to see what you can do.

Leave a Comment

Custom Calendars in Power BI

Kenneth Omorodion needs a calendar dimension:

Before September 2025, there was a complex workaround to create time intelligence calculations in DAX catered to different calendar types apart from the standard Gregorian calendar. With the Power BI September 2025 feature updates (still in preview at the time of writing), it is now readily possible to define custom Power BI custom calendars based time intelligence, like Shifted Gregorian, ISO, and retail calendars, in the data model and then use the new extended DAX functions against these calendars.

The new feature eliminates the need for complex workarounds and ensures cleaner and more accurate reporting for organizations. This tip will explain the different calendars used in time intelligence reporting and how to define them based on the new calendar-based time intelligence capability in Power BI.

Read on for several examples of how this works.

Leave a Comment

PostGIS Tuning via pg_stat_statements

Paul Ramsey wants to make spatial querying faster:

A reasonable question to ask, if you are managing a system with variable performance is: “what queries on my system are running slowly?”

Fortunately, PostgreSQL includes an extension called “pg_stat_statements” that tracks query performance over time and maintains a list of high cost queries.

This particular post is more about pg_stat_statements in general rather than specific advice for PostGIS, but it does lay out some recommendations for using pg_stat_statements in spatial-heavy environments.

Leave a Comment

Microsoft Fabric Direct Lake Join Index Creation

Phil Seamark explains a recent change:

If you’ve been working with Direct Lake in Microsoft Fabric, you’ll know its magic resides in its ability to quickly load data. It loads data into semantic models from OneLake when needed. This feature eliminates the overhead of importing. But until recently, the first query on a cold cache might feel sluggish. Why? One reason for this is that Direct Lake must build a join index. This index is added to the model during the first query. This index is a critical structure that maps relationships between tables for efficient lookups.

Earlier, this process was single-threaded and slow, especially on large tables with high cardinality. The good news? That’s changed.

Read on to see how, what a join index is, and what this impact looks like in practice.

Leave a Comment

Learning Microsoft Fabric Real-Time Intelligence

Valerie Junk picks up a new skill:

If you are reading this article on my website, chances are you know me from my Power BI content, the videosarticlestutorials, or downloads, or you came across it on LinkedIn. I want to be upfront: I am a front-end/business person. I create reports that lead to action and help businesses make smarter decisions while building a data-driven strategy.

When I started talking about Fabric Real-Time Intelligence, people were surprised. Some were curious. Others probably wondered what had happened. For me, real-time reports push you to approach design in a completely different way because users need to take action immediately. Decisions happen in the moment, and that changes everything about how you visualize and structure information, so that got me interested!

Read on to see how Valerie picked up KQL as a language, as well as some of the challenges involved. I will say, the Eventhouse is also the fastest mechanism Microsoft has to query large amounts of data in Microsoft Fabric—it beats out the lakehouse and warehouse pretty handily.

Leave a Comment

Breaking Changes in SQL Server 2025

Rebecca Lewis goes over the list:

Every new SQL Server release comes with shiny features — but SQL Server 2025 brings more than just enhancements. It’s important to know that there are several breaking changes under the hood that could futz your upgrade if you’re not paying attention.

On the whole, it’s a pretty small list but there are a few things on here that could affect any given environment.

Leave a Comment

TempDB Resource Governor in SQL Server 2025

Brent Ozar tries out an update to resource governor:

We’ve finally got a way to defend ourselves. We can configure Resource Governor to divide people into groups (something that seems to be trendy lately), and then cap how much TempDB space each group can consume. You don’t even have to divide them into groups, either (take note, politicians) – you can just cap how much resources everyone can use altogether.

To keep things simple for the sake of this blog post, let’s just assume we’re limiting everyone’s usage altogether. 

Click through to see how it works, as well as some of the caveats that are going to require foresight before this works the way you’ll want it to.

Leave a Comment

Temporary Stored Procedures in SQL Server

Louis Davidson is only here for a little while:

Pretty much every T-SQL programmer knows about temp tables very early in their journey with the language. They are generally wonderful tools that, when used properly, can be invaluable for storing data for a short amount of time. When used improperly they can be somewhat problematic, but certainly they are a tool we all use regularly.

But did you realize you can create a temporary stored procedure as well? It is not something I had ever used before, and while I remember hearing they existed a few times over the years, I had never tried them. The other day. I was creating an informal demo of some data, and once I had written the main query that listed rows that needed to be looked at, I needed a way to display the details of some rows.

I’ve worked with production code that included temporary stored procedures one time, I think. Otherwise, I’ve never used them either. But read on as Louis takes us through the utility of this concept.

Leave a Comment