A few observations on Common Table Expression (CTE): it does not replace temp tables, begin it with a semicolon, and its scope is one statement.
SQL SERVER – What Kind of Lock WITH (NOLOCK) Hint Takes on Object?
What kind of lock does WITH (NOLOCK) take? Vinod Kumar made me think again: it takes a schema lock, and a quick query on sys.dm_tran_locks proves it.
SQL SERVER – 2008 – 2008 R2 – Create Script to Copy Database Schema and All The Objects – Data, Schema, Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects
Use the SQL Server script generator wizard to copy database schema, data and all objects, then run the large script with SQLCMD on the new instance.
ROWS vs RANGE in Window Frames: Why Running Totals Differ
Compare ROWS vs RANGE for running totals, handle tied sort values, write explicit frames, and check worktable reads on your server.
XML sql:column: Compare XML With a Relational Value
XML sql:column passes a typed relational value into XQuery. Keep node existence separate from a missing document and a scalar Boolean.
SQL SERVER – Performance Improvement with of Executing Stored Procedure with Result Sets in SQL Server 2012
How fast are result sets in SQL Server 2012 compared with a temp table? I ran both methods and compared their execution plans to answer a reader.
SQL SERVER – CTAS – Create Table As SELECT – What is CTAS?
CTAS stands for Create Table As Select. In SQL Server you do it with SELECT INTO, which creates the new table and fills it with data in one step.






