if object_id('tempdb..#t') is not null
drop table #t
if objectproperty ( object_id('tempdb..#t'),'istable') = 1
print 'authors is a table'
else if objectproperty ( object_id('tempdb..#t'),'istable') = 0
print 'authors is not a table'
else if objectproperty ( object_id('tempdb..#t'),'istable') is null
print 'error: authors is not an object'
或者簡單一點
if ( object_id('tempdb..#t') is not null ) --- temp table has been created!
判斷MS SQLSERVER臨時表是否存在
drop table tempcitys select into tempcitys from hy citys 上面的語句第一次執行的時候就肯定出錯了,但第二次就不會。因為select into tempcitys from hy citys自動建立了臨時表 tempcitys 第一次臨時表不存在...
T SQL判斷是否存在表 臨時表
利用sql server的系統函式 object id 可以判斷是否存在表 臨時表,object id 的作用是返回架構範圍內物件的資料庫物件標識。即返回系統檢視 sys.objects 的 object id 字段值 object id database name schema name sche...
判斷臨時表是否存在 臨時表的刪除
以下是在網上搜尋的乙個說明 臨時表有兩種型別 本地和全域性。它們在名稱 可見性以及可用性上有區別。本地臨時表的名稱以單個數字符號 打頭 它們僅對當前的使用者連線是可見的 當使用者從 sql server 例項斷開連線時被刪除。全域性臨時表的名稱以兩個數字符號 打頭,建立後對任何使用者都是可見的,當所...