sqlserver

SQL Query Stats via Powershell

Andy Levy
Sometimes, work tasks and questions that come up in the SQL Server Community Slack coincide. A couple weeks ago, DrData asked With SET STATISTICS IO ON, is there really no way to show the TOTALS at the bottom? There are some nice tools like StatisticsParser but it sure would be nice to see the totals of all values right at the bottom, especially when there are many tables. The task at hand in the office was a need to do the same thing, but with SET STATISTICS TIME ON.

dbatools Required Filesystem Access for Database Restores

Andy Levy
The Problem While performing an instance migration this spring, I happened upon something I didn’t expect in dbatools. It should have been a simple backup/restore copy of the databases, with the backup files residing on a fileshare on the destination server after being copied there. I kept getting a warning that the backup files I was attempting to restore couldn’t be read, and the restores (via Restore-DbaDatabase) wouldn’t execute. I checked permissions on the server over and over again.

Regular Expressions to Generate Disable/Drop Index Scripts

Andy Levy
Earlier this year, I embarked on a bit of a project to tidy up the indexes in a sizeable database. This database has over 900 tables, and there are quite a few indexes which I have long suspected don’t need to exist for a variety of reasons. Some indexes are redundant, others don’t get used, still others could be combined into a single index. By reducing the number of indexes, we can improve write performance in the database, and the size of the database itself.

Community Tools Month 2022 - dbatools

Andy Levy
The Prompt In July, Brent Ozar (blog | twitter) asked us to make September Community Tools Awareness Month. In September, I want you to improve community knowledge about one free tool that you rely on every week in order to get your job done. I’m sure it will come as no surprise to readers of this blog, but I’m going to select the amazing PowerShell module dbatools. dbatools Is for Everyone Despite what the name may imply, dbatools is a valuable toolkit for anyone who needs to interact with SQL Server.

Why You (usually) Want a Clustered Index

Andy Levy

Note: I originally wrote this a few years ago but never posted it. It resurfaced when I migrated the blog so it’s being posted now.

After watching Kevin Kline’s (blog | twitter) webinar Essential Tasks to a Successful Cloud Migration, I downloaded the T-SQL scripts to run them against some of my databases. One of the included queries identifies tables with forwarded fetches and right on top of the list was a table with over 1.6 billion forwarded fetches in the roughly 3 weeks since the instance was last restarted.

Lesson Learned From Multi-Threading with dbatools

Andy Levy

Over the summer, I spent some (a lot of) time working on updates to a script at work which runs multiple processes in parallel. Everything seemed to work OK for a while, but then everything broke. It broke right around the time dbatools 1.1 dropped, so I started thinking that something must have changed there. As it turns out, it was entirely my fault and I hope this post will help you avoid the same trap.

Troubleshooting Backup Compression for Encrypted Databases

Andy Levy

For years, I thought that native backups of databases using Transparent Data Encryption (TDE) couldn’t be compressed. Between TDE being limited to Enterprise Edition until SQL Server 2019 and my own lack of experience with TDE in prior positions, I hadn’t really experimented with this myself. Some people have even gone so far as to skip compression in their backup jobs for TDE-enabled databases because there’s no need to burn those CPU cycles if you won’t get any compression, right?

T-SQL Tuesday #136: Your Favorite (or Least Favorite) Data Type

Andy Levy
T-SQL Tuesday is a monthly blog party hosted by a different community member each month, and this month Brent Ozar (blog | twitter) asks us to talk about data types. Your mission: write a blog post about your favorite data type, and schedule it for next Tuesday, March 9. Mad about money? Feverish about float? Tell us what you use your favorite data type for, and what people need to know before they get started using it.