When SQL Server is installed the setup program creates the MASTER database device. One of the databases it creates and places on that device is tempdb. This database provides a storage area for temporary tables and other temporary working storage needs. No special permissions are required to use tempdb (that is, to create temporary tables or to execute commands that might require storage space in the tempdb database).
All temporary tables are stored in tempdb, no matter which database the user who creates them is using. You can query a temporary table from inside the database in which it was created or from tempdb. If you query tempdb..sysobjects, you will notice that a suffix is attached to the names of temporary tables. System stored procedures (for example, sp_help) work on temporary tables, but only if you use the procedures from tempdb.
The tempdb database is a shared work space used by the databases on SQL Server. A user's temporary tables are dropped from tempdb when the current user leaves SQL Server or during recovery from a system failure. A stored procedure's temporary tables are dropped when the procedure exits. Temporary tables can also be dropped explicitly before a session ends.
The default size of tempdb is 2 MB. Certain activities, such as the following, can make it necessary to increase the size of tempdb:
The system administrator can increase the size of tempdb. Note that tempdb is created on the MASTER device by default. Additional space can be added on MASTER or on any other initialized device. The system administrator can also create tempdb in RAM.