Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating temporary table
Message
 
 
À
04/02/2014 14:16:00
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01593184
Message ID:
01593197
Vues:
31
>>The temporary table is created in the TempDB database under unique name for the session. So, you can create temporary table with the same name in two different sessions. This is for local #temp tables. If we're talking about global temp table ##temp then this table is shared by all sessions created after the session that created that global table.
>
>I really cannot it under TempDB. Where exactly in that branch is this suppose to be?
>
>Also, I guess I would need to verify to delete it if it exists, as you suggested, as well as regular deletion at the end of the command, which will be the normal case. So, the table will only exist for a fraction of a second if I understand correctly. I am not sure about performation issue as we are creating something on disk then. Is that correct?
>
>>You may want to check this interesting article by Peter Larsson
>>
>>http://sqlblog.com/blogs/peter_larsson/archive/2009/10/15/performance-consideration-when-using-a-table-variable.aspx
>
>Thanks, I will check it out.

All # temp tables are created in the TempDB database. The memory table variable @tableList is also created in the TempDB. I am not sure why do you need to worry much about them. The TempDB database is automatically recreated every time the server is re-started.

The temporary table is dropped automatically by SQL Server when the session creating this table is closed. So, you don't have to DROP table at the end of the session although you may. I believe I read in Transact-SQL MSDN forum by both Tibor K and Erland Sommarskog that it's better to let SQL Server to drop these tables rather than perform manual clean up.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform