When creating temp tables within a stored procedure, is it good practice to drop them as soon as they are no longer required?

Ideally, for best SQL Server performance, you should avoid using temp tables in the first place. Instead, consider using one of these “lower overhead” options instead of using a “higher overhead” temp table.

  • Rewrite your code so that the action you need completed can be done using a standard query or stored procedure.

  • Use a derived table.

  • Use the SQL Server 2000 or 2005 “table” datatype.

  • Consider using a correlated sub-query. 

  • Use a permanent table instead.

  • Use a UNION statement to mimic a temp table.


Leave a comment

Your email address will not be published.