|From this article[^]
If you remove the
Quote:Another oddity of the local temporary table (and the local temporary stored procedure) is that it has a different name in the metadata to the one you give it in your routine or batch. If the same routine is executed simultaneously by several processes, the Database Engine needs to be able to distinguish between the identically-named local temporary tables created by the different processes. It does this by adding a numeric string to each local temporary table name left-padded by underscore characters. Although you specify the short name such as #MyTempTable, what is actually stored in TempDB is made up of the table name specified in the CREATE TABLE statement and the suffix. Because of this suffix, local temporary table names must be 116 characters or less.
where from your code you will see that the table name is actually
#tmp_table__________________________________________________________________________________________________________000000000002So you do need to use a
like clause but not the one you have commented out. Like this
where t.name LIKE '#tmp_table%'