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 ...

Get Inside Microsoft® SQL Server™ 2005 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.