Press "Enter" to skip to content

Curated SQL Posts

RedGate’s State of the Database 2025

Louis Davidson summarizes a report:

Less than a week ago, Redgate released their annual State of the Database Landscape report. You can read about the methodology and see some of the results on this page. If you want the entire report, you can download that from the same page.

What I really love about this survey is that it is very low on opinions and sticks largely to the facts. As a person working with data, most of these facts will make you feel that you are not alone. Sometimes, it is easy to start thinking that your company is the only one in a given situation. 

Click through for some of Louis’s findings.

Leave a Comment

Deleting All Items from a Microsoft Fabric Workspace

Sandeep Pawar has a script:

A handy function to delete all Fabric items in a workspace. Run this in a Python notebook in the workspace you want to delete items from. Everything, except that notebook, will be deleted. You need to have contributor+ role in the workspace. Delete the last remaining notebook manually.

Read on for the script. This one’s pretty straightforward, so there isn’t a lot in the way of additional commentary.

Leave a Comment

Using MIRROR TO in a Backup Operation

Andy Yun tries out an option:

About a month ago, was having a conversation with a Pure Storage customer’s SQL Server backups. They were using Ola Hallengren’s scripts but mentioned something about writing the backups to multiple locations at once. I presumed they were executing the backup operation as normal, then using another script of some sort to then copy the backup files elsewhere. That’s when I learned that Ola has a parameter called MirrorDirectory, that exposes the MIRROR TO option in a native BACKUP command.

Click through to learn more about this command and the implications. I’d say that this sounds neat but also isn’t something I’d probably recommend.

Leave a Comment

Default Domain Settings in Microsoft Fabric

Nicky van Vroenhoven continues a series on governance in Microsoft Fabric:

A short introduction to Domains: they are essentially a way of managing and structuring your data across the organization. You can logically group together data in workspaces. A logical grouping can be business units, areas, fields, solutions or actually whatever works for you. It shouldn’t be something a Fabric Admin decides on his own. Ideally business and / or enterprise architects with the data owners (if any) should implement the design of domains, subdomains and owners. People from you Center of Excellence (again: if available..) would be a good fit to include in this discussion.

In case you need some help or guidance on how to set up your domains, there’s a nice article that can help you get started: Best practices for planning and creating domains.

Click through to learn more about domains and default domain settings.

Leave a Comment

Discerning the Value of an Empty Table

Andy Levy performs some database archaeology:

It seems like no matter how long you work with a system beyond a trivial size, you’ll find something new every so often. A little while ago, I found a table without about a dozen columns, no data, and was referenced in only one place across an entire database hosting nearly 1000 tables and over 8000 stored procedures. Why does this thing even exist?

To protect the innocent(ish?), obviously I’m changing the names of everything here. I was looking into some performance issues and found a very short stored procedure being called from another stored procedure which opened with this query:

Click through for the query and why it existed in the first place.

Leave a Comment

The Implications of TABLOCK in SQL Server

Haripriya Naidu locks the table:

TABLOCK can greatly improve insert performance under the right conditions, but it has some implications to consider. It’s important to understand where this hint cannot be used to avoid shooting yourself in the foot, specifically due to the locking behavior of TABLOCK.

In this article, we’ll explore how TABLOCK’s locking behavior makes it less suitable for tables that cannot afford significant blocking.

Click through for a demo and some takeaways.

Leave a Comment

Lock Escalation in SQL Server

Stephen Planck talks lock escalation:

Lock escalation is a built-in mechanism in SQL Server designed to optimize how the database engine manages locks. By reducing thousands of fine-grained locks (such as row or page locks) to a single table-level lock, SQL Server aims to lower overhead in the lock manager. In practice, lock escalation saves system resources but can also introduce challenges in high-concurrency environments. This post explores why lock escalation happens, how it works under the hood, the problems it can cause, and strategies to prevent or mitigate unwanted escalations.

Read on for the full story.

Leave a Comment

Saving Money in Microsoft Fabric by Automatic Pause and Resume

Soheil Bakhshi saves us some cash:

If you work in data and analytics, particularly within the Microsoft Data Platform, you have likely heard of Microsoft Fabric and its many capabilities. However, one of the biggest challenges organisations face is managing costs effectively.

In previous blogs and videos, I have covered how to optimise Microsoft Fabric capacity costs by automating the pause and resume process using Logic Apps. This approach ensures that your Fabric capacity runs only when needed, reducing unnecessary expenses. But how much can this method actually save? In this post, I share the real cost-saving results after applying this automation over the past few months.

Click through for some information on how much Soheil saved over a six-month period.

Leave a Comment

Customer KPIs in T-SQL

I have a new video:

In this video, we will take a look at several useful KPIs for measuring customer growth. We will also demonstrate the utility of DATETRUNC(), calendar tables, and the LAG() and LEAD() window functions.

The calendar table (or date dimension) interlude may seem a little bit weird at first, but I firmly believe that calendar tables absolutely belong on basically every SQL Server instance, even if only in a utility database.

Leave a Comment