Comparison Summary
Table 2-4 contains a summary of the functionality and behavior of the different object types. Note that I didn’t include global temporary tables because typically you use those for different purposes than the other types of temporary objects. You might find this table handy as a reference when you need to choose the appropriate temporary object type for a given task.
Table 2-4. Comparison Summary
Functionality/Object Type | Local Temp Table | Table Variable | Table Expression |
|---|---|---|---|
Scope/Visibility | Current and inner levels | Local Batch | Derived Table/CTE: Current statement View/Inline UDF: Global |
Physical representation in tempdb | Yes | Yes | No |
Part of outer transaction/Affected by outer transaction rollback | Yes | No | Yes |
Logging | To support transaction rollback | To ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access