Forget about BINARY_CHECKSUM in SQL Server!

checksum smallSQL Server has a few functions that allow calculating a hash from a single value or multiple values. They could be very useful if they worked reliably. Unfortunately, they do not. This article shows how to use CHECKSUM and BINARY_CHECKSUM functions and why you should not rely on them. And I do not only mean the collision probability!

Why my view does not show this column?

viewWhen using SQL Server you may have an impression that not everything works exactly how you would expect. One of those things may be a view that does not contain a column that you added to the source table. In this article I will explain you why it works like that and how to refresh columns in the view. 

Problems with sp_rename

renamedTable smallUnsupported or undocumented functions are not surprising in IT software. SQL Server also has some, for example very useful sp_who2. If it suddenly stops working, do not blame Microsoft - they have never encouraged you to use it. Leaving undocumented commands behind, there are also stored procedures that are well documented and supported but not recommended to use. One of them is sp_rename which I am writing about.

Script to shrink tempdb

shrinkIn general shrinking a database is easy. This operation is done when an administrator wants to make database files smaller. It can be even done with SQL Server Management Studio. It becomes a little more complex when the database is tempdb. It is a system database that stores different types of temporary objects. As a consequence, it cannot be easily shrinked to reduce occupied disk space. This post contains a script that allows for that.


What?! SELECT query caused a deadlock?

deadlockVideoDeadlocks. We all know a lot about them, right? A sample scenario is simple - one process (A) deadlocks with another one (B) when they acquire locks in a different order. A waits on B and B waits on A. One of them has to be killed to resolve the situation. Is that all? Not really. If you work with SQL Server you might have experienced a deadlock when one of the processes was executing a SELECT query and nothing else. It is surprising at the first glance, but actually it makes sense. Watch my video explanation.