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.
Performance Challenge – Write Efficient Query – SQL in Sixty Seconds #140
Recently while working with my client I ended up in a very interesting situation where my client wanted me to write an Efficient Query.
Scan Count Zero in STATISTICS IO: What the Number Means
Scan count zero in STATISTICS IO is not an error and not a free read. This post runs nine small queries and shows what 0, 1, 2 and 5 mean, why a unique lookup counts as zero, and why logical reads are the number to compare.
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.
Oldest Statistics in SQL Server: Find the Stale Ones First
To find the oldest statistics in SQL Server, read the last update time and the number of changes since. This post builds a small demo, lists every statistic with its age and percent changed, and shows why a high change count on its own is not a reason to update by hand.
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.







