CHOOSE returns an item from a positional list. Check unsupported indexes and compare a consistently typed CASE expression with an explicit fallback.
STUFF Boundaries: Insert Text and Handle NULL Results
STUFF boundaries govern insertion and deletion. See valid positions, zero length, NULL replacement and out-of-range starts.
SQL SERVER – Difference between DISTINCT and GROUP BY – Distinct vs Group By
What is the difference between DISTINCT and GROUP BY? They usually produce the same plan. Use GROUP BY for aggregates and DISTINCT to remove duplicates.
SQL SERVER – @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT – Retrieve Last Inserted Identity of Record
@@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT: how each one returns the last identity value, and why a trigger can make @@IDENTITY give the wrong one.
SQL SERVER – Script to Determine Which Version of SQL Server 2000-2005 is Running
A quick way to see which version of SQL Server 2000 or 2005 is running: SERVERPROPERTY returns the product version, the product level and the edition.
WINDOW: Reuse an Explicit Running-Total Frame
WINDOW lets me name a window definition and reuse it across compatible calculations. I still specify the partition, ordering and frame. A short name should make the intended calculation easier to review.







