Is today a weekend or a weekday? A question from the very first SQL Bangalore User Group meeting, answered with the CHOOSE function in SQL Server 2012.
Cursor Options That Matter: LOCAL, FAST_FORWARD and STATIC
Test SQL Server cursor options, including LOCAL FAST_FORWARD and STATIC, on one loop while measuring time and tempdb cost.
sys.dm_os_waiting_tasks: Who Is Waiting Right Now and Why
sys.dm_os_waiting_tasks shows every task that waits right now, what it waits for and who is in the way. This post builds a three-session blocking chain on SQL Server 2025, reads the view, finds the head of the chain and names the locked table.
SQL SERVER – Removing Leading Zeros From Column in Table – Part 2
Part 2 on removing leading zeros from column values: readers improved my sample with all-zero values and shared better methods, collected here.
Display Datetime in a Specific Format: CONVERT and FORMAT
To display datetime in a specific format, use CONVERT with a style number or FORMAT with a pattern. This post tests both on a fixed value, shows the lowercase pattern mistake, measures how much slower FORMAT is, and explains why parsing text dates needs a style.
SQL SERVER – Using RAND() in User Defined Functions (UDF)
Using RAND() in a user defined function throws Msg 443, invalid use of a side-effecting operator. Here is a simple workaround that lets a UDF use a random value.
SQL SERVER – Removing Leading Zeros From Column in Table
Most people ask how to keep leading zeros in SQL Server. This time a reader wanted to remove leading zeros and white space from a column, so here is a script.







