I show how I tried to chase down a very unexpected issue with SQL Server metadata. Spoiler: it didn't end the way I thought it would.
SQL Server
Discover a simple way to keep your filtered indexes effective – even under forced parameterization.
Conventional wisdom has suggested that deletes should be batched, but in some cases this can actually take a lot longer.
See how to generate a set of scripts that will delete rows from dependent tables and show you how many rows will be deleted from each.
For this month's T-SQL Tuesday, I talk about an incident where I've changed my mind about something I was previously pretty stubborn about.
Find out how to use dynamic SQL to quickly generate metadata queries to pull attributes for all columns across a database or even a set of databases.
Forced Parameterization can be a useful setting to tune workloads, but this can work against you if you're also using filtered indexes.
Give your Docker containers meaningful port numbers to avoid confusion, especially when presenting or giving demos.
Originally published in 2009, I updated this in 2019 with an example showing an effect on the plan cache.
Did you know that not all characters can be used as the separator for STRING_SPLIT?
Read about an approach to partitioning a result set without the performance impact of NTILE.
Discover some of the new information SQL Server keeps adding to help us troubleshoot query plans.
One of the biggest downsides of using SQL Server Management Studio as an interactive query tool is the limit on text/grid output. SSMS 18.2 fixes that!
In this tip, you'll see the metadata queries that will make it possible to discover which integer-based columns could be made smaller (without any loss of data).
I explain four conventions I always follow when writing T-SQL queries.
See how you can use new functions like DATEFROMPARTS to simplify otherwise really cryptic methods to obtain key dates (like the first day of the current month).
Get a first-hand look at some of the ways NOLOCK can produce incorrect data.
Aaron Bertrand talks about a few of the things that he wished he had learned earlier on.
This tip shows how powerful the CASE expression is, and some of the nuances in its behavior.
See one approach to collecting extended properties information across all of the databases on a server.
Break free from the limitations of history retention and take control at the job or even step level.
In part 2 of this series, we add another way to further isolate multiple threads of a bulk import process.
In the first of a 2-part series, see how you can easily reduce contention between multiple bulk import threads.
This tip shows a neat trick with CROSS APPLY that lets your metadata queries ignore columns that don't exist yet.
If you use scalar user-defined functions, and can't take advantage of new handling in SQL Server 2019, see some other ways to reduce the impact on performance.
Simplify your date range calculations when trying to find events that overlap (or don't).
Microsoft has pulled several patches for older versions of SQL Server. If you need TLS 1.2 support on an unsupported version, your recourse is to contact Microsoft support.
Some additional details about this sp_MSforeachdb (and sp_foreachdb) replacement.
I talk about the top 10 wait types observed among SentryOne customers, and where to turn when you experience one of them on your own system.
This replacement for sp_foreachdb makes even more improvements over the original system procedure, sp_MSforeachdb.
I show that, in some cases, INSTEAD OF triggers can be better for performance than AFTER triggers.
I talk about the pros and cons of letting SQL Server wait to get a more accurate cardinality estimate from a table variable.
I discuss a queue table for DDL notifications instead of handling them within a DDL trigger.
This tip was refreshed with status updates for some of the critical bugs discovered in MERGE over the years.
SQL Server will gladly tell you about missing indexes, but it may not give you the keys in the right order.
GDPR is a big deal for a lot of us; in this tip I explain how you might want to deal with "forget me" requests.
I show how to denormalize data using FOR XML PATH and STRING_AGG, and explain which one is faster.
Privacy laws are going to make us all much more careful about how we handle data archival and purge processes.
I show how to enable, disable, drop, and re-create all triggers in a database using dynamic SQL.
Estimated data size as a result of implicit conversions can make a huge difference in the execution plan.
In this tip, I talk about a slightly more flexible way to simulate TRY_CONVERT() on unsupported versions of SQL Server.
If you are still stuck on an unsupported version of SQL Server, there may still be a way for you to have TRY_CONVERT() functionality.
Check this list for possible problems if you have trouble connecting using the Dedicated Administrator Connection.
This was mostly tongue-in-cheek, but I show that there is no performance difference between tabs and spaces. (There is, however, a better reason to prefer tabs: accessibility.)
I address several questions raised during two parameter sniffing webinars I presented with Kimberly L. Tripp and Andy Mallon.
You can now enable this setting at the database level, optimizing performance there while not violating support for other vendor databases (like SharePoint).
See a few creative ways to make use of STRING_AGG() and STRING_SPLIT().