Bad Habits & Best Practices

T-SQL Tuesday #154: SQL Server 2022

For this month's T-SQL Tuesday, I talk about a not-quite-yet-announced feature in SQL Server 2022 that has the potential to function as a low-effort bad habit logger.

Bad Habits to Kick: Abusing bit columns

I talk a bit about bit columns: names with negative context, allowing NULLs, and using cryptic BITWISE operators instead of readable, self-documenting expressions.

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.

MERGE with caution

This tip was refreshed with status updates for some of the critical bugs discovered in MERGE over the years.

Bad Habits to Kick: AttachDBFileName

I point out that an often-used connection setting, AttachDBFileName, may be the source of many wasted hours of debugging and troubleshooting.

Bad Habits to Kick: The uber-view

I talk about creating a view that joins all the possible tables, and suggest that simplification isn't always worth it.