Word wrap in SSMS folds a long line of T-SQL at the edge of the window, so you read it without scrolling sideways. This post shows where to turn it on for every window, how to show the wrap marks, how to switch it for one window, and why it never changes your script.
SQL SERVER – DISTINCT Does Not Guarantee ORDER BY
DISTINCT removes duplicate result rows without guaranteeing their order. My original claim that it always sorts output was incorrect.
DDL in a Transaction: What Rolls Back and What Blocks
DDL in a transaction works in SQL Server: CREATE, ALTER and DROP roll back like any other change. This post proves it with a small demo, lists the statements that are refused inside a transaction, and shows which locks an open DDL transaction holds and who has to wait for them.
Rewriting Correlated Subqueries as Window Functions
Replace correlated subqueries with windowed counts, dates, and running totals, preserve detail rows, and keep useful EXISTS filters.
Check Constraint on Identity Column: Why Inserts Fail
A check constraint on identity column values can make every insert fail, because the identity moves on whether or not the row is accepted. This post reproduces the failure, shows that the failed attempts still use up identity values, and lists every such constraint in a database with one query.
Add Columns With NULL in SQL Server: ISNULL, COALESCE or SUM
To add columns with NULL in SQL Server, first decide what an empty value means. This post sums three nullable columns with the plus operator, ISNULL, COALESCE and SUM, shows where each one differs on a row of all NULLs, and compares their CPU cost on two million rows.







