1

.Net application runs a query that creates a global temp table ##Table1, i need the table to persist for a while as i sync the data to an external source over WCF. As part of my query i check to see if the table exists and drop before creating it, this is always returning 'table not exists', but when i query TABLE_NAME from tempdb.information_schema.Tables it shows ##Table1 as in there.

IF OBJECT_ID('##Table1') IS NOT NULL 
DROP TABLE ##Table1
ELSE
PRINT 'Table Not Exists'
GO
select TABLE_NAME from tempdb.information_schema.tables
GO

This is always returning false?

dan h
  • 73
  • 1
  • 10

1 Answers1

0

You need to use OBJECT_ID('tempdb..##Table1')

hook
  • 984
  • 7
  • 7