A quick script to split one column into two with LEFT, RIGHT and CHARINDEX, plus what to check when a value has no comma or has extra spaces.
SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 2
Mihir Popat improved my Day of the Week Function with @@DATEFIRST, so Sunday does not have to be the first day of the week. Here is his UDF.
SQL SERVER – PIVOT Table Example
A PIVOT Table example on AdventureWorks that counts addresses by state, plus why UNPIVOT cannot always give you back the original rows.
Bit Shifts: Move Bits Without Rotating Them
Bit shifts fill vacant positions with zero and discard bits past the type width. Compare tinyint with int and a negative shift direction.
SQL SERVER – Function Property – Deterministic or Non-Deterministic
How do you tell if a user defined function is deterministic or non-deterministic? One OBJECTPROPERTY call with IsDeterministic gives you the answer.
XQuery distinct-values: Deduplicate Atomic Values, Not Nodes
XQuery distinct-values removes repeated atomic values rather than selecting representative source nodes. I rebuild a small sorted XML result from repeated text. The example also keeps an empty document in view.







