T-SQL object selection: CTAS vs stored procedure vs view vs function

Verdict: Use CTAS to create and load a new table in one statement. Use a stored procedure for parameterised, multi-step loads with inserts, updates and branching, invoked by name from a pipeline. A view stores a query; it holds no rows.

CriterionCTASStored procedureViewScalar function
What it doesCreates and populates a new table in one statementEncapsulates parameterised multi-step logicStores a reusable SELECT definitionReturns a single computed value
Persists dataYes, physical tableVia its DMLNo, virtualNo
DML and branchingOne-time load onlyYes, insert, update, conditionalNoNo
Invoked from a pipelineAs a statementBy name with EXECReferenced in queriesUsed in expressions
Choose whenBuild or stage a summarised table from existing dataScheduled multi-step incremental loadConsistent query definition without storing rowsCompute one value in a query

Rules

Traps