Issue dropping ##Table



.NET应用程序运行一个创建全局临时表## table1的查询,我需要该表可以持续一段时间,因为我将数据同步到WCF上的外部源。作为我查询的一部分,我检查表是否存在并在创建它之前掉落,这总是返回"表不存在",但是当我从tempdb.information_schema.tables询问table_name时,它显示了## table1。

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

这总是返回false?

您需要使用OBJECT_ID('tempdb..##Table1')

最新更新