Temporary Tables

SQL Server supports two types of temporary tables: local and global. For the most part, I’ll focus on local temporary tables because this is the type you would typically consider in the same situations as table variables and table expressions. I’ll also describe global temporary tables, but these typically have completely different uses than local temporary tables.

Local Temporary Tables

I’ll start with some fundamentals of local temporary tables before showing examples, and I’ll do the same whenever discussing a new temporary object type. When referring to temporary tables in this section, assume that the discussion pertains to local ones.

You create and manipulate a temporary table just as you would a permanent one, for the most ...

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.