Press "Enter" to skip to content

Curated SQL Posts

Database Snapshots in High-Availability Setups

Stephen Planck adds one more layer of complexity:

SQL Server’s database-snapshot feature is a wonderfully simple tool: at the instant you create the snapshot, every page in the database is marked “copy-on-write.” Nothing is copied across the wire, no blocking locks appear, and the snapshot opens immediately as a read-only database on the local replica. Queries against the snapshot see the world exactly as it looked at that moment while the live workload keeps changing pages in the primary data files. Because snapshots live only in sparse files on the server that owns them, they are not a replacement for backups—but they are perfect for ad-hoc reporting, quick “before-and-after” comparisons, or a safety net when you want an easy way to back out a risky change that should finish within minutes or hours.

But read on to see how they interact with high-availability features such as transactional replication and availability groups.

Comments closed

Self-Healing in SQL Agent Jobs

Rob Douglas doesn’t want to click the button a second time:

Recently, someone made an off the cuff comment about using TSQL Tasks in Maintenance Plans to handle more complex logic that SQL Agent handled out of the box. I was briefly excited by the prospect of building improved logic flows directly into SQL Server Maintenance Plans. This months Andy Levy hosts TSQL Tuesday and asks us about how we handle SQL Agent Jobs and this seemed like a great opportunity for me to share a story about how I wasted an afternoon testing a few components I have a passing knowledge with, attempting to implement auto-healing and conditional logic flow, only to snap out of it a few hours later when I realized that I was trying to solve a problem that someone else cracked nearly 2 decades ago.

Click through for the example. Some people might think of this kind of spelunking as a waste of time. My counter-argument is that it is better to know three ways of doing a thing versus one, as inevitably, you’ll run into the situation in which the one way is either not workable or is such a bad option that it’s painful to implement.

Comments closed

PARSE_SYNTAX_ERROR in Microsoft Fabric Notebooks

Olivier Van Steenlandt runs into an error:

As mentioned earlier, I have been playing around with Microsoft Fabric intensively in the past few months. During this period, I ran into a specific issue with one of my notebooks. What happened? Well, I was starting on a new notebook in the evening and life happened… So I stopped playing around to do something else.

A few days later, I wanted to continue my work and remembered that I was required to change something in my data load from a csv file.

Read on for the cause of this error. It’s something that can affect anyone at any time. Even you. Well, probably not you, but the person next to you? Yeah, even that person.

Comments closed

Visualizing SQL Agent Job History

Andy Levy wants a picture or at least a thousand words:

If you don’t have a monitoring suite watching SQL Agent, or you want to get a bigger picture view of when and how your Agent jobs are running, dbatools can help you shortcut getting this information. Get-DbaAgentJobHistory does exactly what its name suggests – it fetches the execution history for one or more Agent jobs on one or more SQL Server instances. Thing is…it can produce a lot of output if you’re not careful.

Read on to see how you can use this to generate a visual indicator of when your jobs are running and how they fare.

Comments closed

Customizing Parameter Display in Power BI Paginated Reports

Andy Brownsword doesn’t like having parameters all helter-skelter:

Parameters in Paginated reports allow for us to tailor report contents based on user selected criteria. These were inherited from Reporting Services as a precursor to the slicers and filters in Power BI reports.

Coming from a Reporting Services background I have a soft spot for pre-defined paginated reports. However these parameters can sometimes get a little unruly. Here we’ll see what that looks like and how we can go about resolving the issue.

Click through to see what this means, as well as how you can fix it. Or embrace the chaos, your choice.

Comments closed

Billing and Microsoft Fabric Preview Features

Nicky van Vroenhoven explains that TANSTAAFL:

First of all, when using Preview features in Fabric, you should be aware of the small print.

Next, we all know, there’s no such thing as a free lunch, right?

Because: preview does not mean free! Let me explain.

Two of those preview features – SQL Database and Workspace Monitoring – have recently moved to a charging model as Fabric develops further. It’s essential to understand these adjustments if you want to maximize your resources, govern your capacity and efficiently control expenses.

Read on to learn more. It’s very uncommon for preview features in Azure to come with a bill, so make sure you don’t get surprised by these.

Comments closed

Troubleshooting resmgr:cpu quantum in Oracle

Kellyn Gorman continues a series on performance tuning in Oracle:

Let’s break it down:

  • RESMGR = Oracle Resource Manager
  • CPU Quantum = The time slice a session is allowed to consume CPU

This wait event indicates that a session is throttled by Oracle Resource Manager because it’s trying to use more CPU than its current consumer group allows. This is intentional: Resource Manager is designed to prevent a single user or group from monopolizing system resources.

Read on to learn more about this wait type and what you can do if you experience it.

Comments closed

The Script-Based Nature of SQL Agent Jobs

Rob Farley praises the textual nature of SQL Agent jobs:

Of course, there are some things that I don’t like about SQL Agent. For example, I’ve never been a big fan of the Operator stuff. I’m sure there are organisations that leverage every feature of it, including pagers, but that has never been me or my clients. Reports that show the status of the jobs are generally more useful than simply relying on Job Notifications (although this also varies from client to client), but on the whole, it’s an area I’m okay, but not writing home about.

The thing I’m going to write about today though – one of my favourite aspects of SQL Agent Jobs – is that it’s all so scriptable.

Read on to learn more. I agree with Rob: it took a little while for me to understand (i.e., actually read what the job is doing), but I like that there’s nothing magical about SQL Agent and that you can simply put this into source control or even draft your own jobs without the UI once you understand the process well enough.

Comments closed

Data Recovery in SQL Server without a Backup

Rodrigo Riberio Gomes digs in:

In more than 10 years of experience, I have dealt with cases where someone has performed incorrect operations on a table, such as updating or deleting wrong rows, in a SQL Server database that does not have full backups available. There are multiple reasons for no full backup: corrupted backups, taking too much time to restore, etc.

In this post, I want to show an alternative for these cases, an ace up one’s sleeve, that you can use to recover data. This method also provides a deep understanding of the internal workings of how your SQL Server stores data. So, in addition to learning how to recover data, you will gain more insights into the internals of SQL.

Read on to see how. Rodrigo also points out some limitations or things that would need to change if you have index compression. I consider this a very neat thing you might need to know but never want to use.

Comments closed

Comparing Microsoft Fabric Engines

Nikola Ilic performs a comparison:

Before we proceed, an important disclaimer: the guidance I’m providing here is based on both my experience with implementing Microsoft Fabric in real-world scenarios, and the recommended practices provided by Microsoft. 

Please keep in mind that the guidance relies on general recommended practices (I intentionally avoid using the phrase best practices, because the best is very hard to determine and agree on). The word general means that the practice I recommend should be used in most of the respective scenarios, but there will always be edge cases when the recommended practice is simply not the best solution. Therefore, you should always evaluate whether the general recommended practice makes sense in your specific use case.

Click through for a comparison between three engines: the lakehouse, the warehouse, and the eventhouse. It would really simplify things if the lakehouse and warehouse combined into one coherent whole.

Comments closed