Need only some columns from a stored procedure resultset? Store it in a temp table with INSERT INTO and EXEC, then select what you need.
SQL SERVER – How to Access the Previous Row and Next Row value in SELECT statement? – Part 4
Part 4 on reading the previous row and next row value in a SELECT statement. My friend Szymon Wojcik shows how a numbers table can make the query even faster.
Turning Key-Value Pairs Into Columns for Reporting
Turn key-value pairs into reporting columns with conditional aggregation and PIVOT, handle missing values and conversions.
SQL SERVER – Simple Puzzle with UNION Part 5
In Puzzle with UNION Part 5, the final part, two almost identical queries return the same answer, yet their execution plans are very different. Why?
SQL SERVER – Simple Puzzle with UNION
Try this simple puzzle with UNION and ORDER BY. Guess what each of the three queries returns, and see why one of them fails with Msg 108 and Msg 104.
Table-Valued Parameters: Sending Thousands of Rows in One Call
Send thousands of rows in one call with table-valued parameters, compare round trips, and handle missing column statistics accurately.
Read-Only Filegroups: Locking Away Old Data
Read-only filegroups let you lock old data so nothing can change it by accident. This post moves old rows to their own filegroup, makes it read-only, shows what still works and what fails, and explains how partial backups skip the locked data.







