Difference Between Temp Table and CTE
CTEs...
CTEs...
- Are unindexable (but can use existing indexes on referenced objects)
- Cannot have constraints
- Are essentially disposable
VIEW
s - Persist only until the next query is run
- Can be recursive
- Do not have dedicated stats (rely on stats on the underlying objects)
- Are real materialized tables that exist in tempdb
- Can be indexed
- Can have constraints
- Persist for the life of the current CONNECTION
- Can be referenced by other queries or subprocedures
- Have dedicated stats generated by the engine