HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Benefits of droping a temporary table

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
dropingbenefitstabletemporary

Problem

What are the benefits (if any) of dropping a temporary table in SQL Server?

eg:

DROP TABLE #temp;


Since temporary tables are automatically dropped by the server this statement would seem to be non-functional.

Solution

I typically drop #temp tables explicitly just out of habit (I like cleaning up anything I create). There is a myth out there that dropping a #temp table explicitly will prevent #temp table caching and reuse, but this is not true: See this blog post by @PaulWhite for a lot more details, and this one for even more.

Context

StackExchange Database Administrators Q#52358, answer score: 7

Revisions (0)

No revisions yet.