CASE expresses the DECODE mapping in this SQL Server example. I keep the named matches and default value explicit.
SQL SERVER – Potential Bottlenecks for Performance
At GIDS I was asked to name potential bottlenecks for performance. My old college list still holds: CPU, RAM, hard disk, network and application code.
SQL SERVER – Prevent Constraint to Allow NULL
Why does a CHECK constraint allow NULL? A reader thought it was a bug. I show why it happens and how to write the constraint so NULL is rejected too.
Common Table Expressions for Readability
Common table expressions for readability name query steps and support recursion, but they do not promise cached intermediate results.
geometry STDistance: Measure the Closest Points of Two Shapes
geometry STDistance measures the shortest distance between points belonging to two represented shapes. I compare an interior gap with an endpoint gap. Intersecting shapes provide a useful zero-distance case.
SQL SERVER – Applying NOLOCK Hint at Query Level – NOLOCK for whole Transaction
Can you apply the NOLOCK hint to a whole query with OPTION (NOLOCK)? No, it fails with Msg 102. Here is how I use an isolation level instead.
SQL SERVER – Making Database to Read Only – Changing Database to Read/Write
A reader attached a client database and it showed as Read Only. Two simple ALTER DATABASE scripts switch a database to READ_ONLY and back to READ_WRITE.






