**
以下是在網上搜尋的乙個說明:
臨時表有兩種型別:本地和全域性。
它們在名稱、可見性以及可用性上有區別。本地臨時表的名稱以單個數字符號 (#) 打頭;它們僅對當前的使用者連線是可見的;當使用者從 sql server 例項斷開連線時被刪除。
全域性臨時表的名稱以兩個數字符號 (##) 打頭,建立後對任何使用者都是可見的,當所有引用該錶的使用者從 sql server 斷開連線時被刪除。
我寫這篇文章的主要目的是,如果判斷這個臨時表是否存在。
1ifobject_id('
tempdb..#temptable
') is
notnull
2begin
3drop
table
#temptable
4end
判斷臨時表是否存在
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 i...
T SQL判斷是否存在表 臨時表
利用sql server的系統函式 object id 可以判斷是否存在表 臨時表,object id 的作用是返回架構範圍內物件的資料庫物件標識。即返回系統檢視 sys.objects 的 object id 字段值 object id database name schema name sche...
判斷MS SQLSERVER臨時表是否存在
drop table tempcitys select into tempcitys from hy citys 上面的語句第一次執行的時候就肯定出錯了,但第二次就不會。因為select into tempcitys from hy citys自動建立了臨時表 tempcitys 第一次臨時表不存在...