Check for existence of temporary table
Another of those tricks that isn't well documented is the ability to check
for the existence of a temporary table.
Many places say it's not possible for #tables, well
they're wrong. object_Id
will return a non null value if you use the following
format tempdb..#temptable combined with object exists, i.e.
if object_id('tempdb..#temptable) is null
--object doesn't exist