2014-01-25 58 views
1

.Net應用程序運行一個查詢來創建一個全局臨時表##表1,我需要該表持續一段時間,因爲我通過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?

+2

見http://stackoverflow.com/questions/8401812/using-object-id-function-with-tables。 –

回答

0

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