I tested this on SQL Server 2005, and you can delete the temporary table in the transaction that created it:
begin transaction create table
What version of SQL Server are you using?
You can review why you drop the temp table altogether. The local temporary table is automatically deleted when the connection is completed. Usually there is no need to explicitly indicate it.
The global temporary table begins with a double hash (fe ##MyTable .) But even the global temporary table is automatically deleted if it does not apply to it.
source share