SQL Server

How to USE a calendar table – Part 1

It seems a lifetime ago I wrote about creating a calendar table; now I've started a new series showing how to use the calendar table. In the first installment, I deal with business day problems.

Performance of sys.partitions

After a question on #sqlhelp, I dug into what could be making sys.partitions slow, and how they might get the required information in a more efficient way.

Please stop using this UPSERT anti-pattern

There is a very common anti-pattern you should avoid, involving updating a row if it exists and inserting it if it doesn't. See how to avoid race conditions and deadlocks.

Sometimes you CAN upsize a column in-place

Altering a fixed-width column on a large table can often mean either a lot of planning or a lot of downtime, but in some scenarios there may be an easy out.

Troubleshooting error 18456

Updated in 2020 with a few new entries, this is a fairly comprehensive list of the reasons behind various 18456 error messages.

Removing the default trace – Part 1

I start a series explaining how I evaluated the default trace and decided to replace it with a slimmer Extended Events session across all of production.

Using metadata to troubleshoot metadata

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.

Simulating ON DELETE CASCADE

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.

T-SQL Tuesday #119: Changing my mind

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.

Document columns across systems

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.