sql server 判斷系統中是否存在某個表,存儲過程 或觸發器
存儲過程
if(exists(select * from sysobjects where name='存儲過程的名字' and Type='P'))
觸發器:
select * from sysobjects where id=object_id(N'觸發器的名字') and objectproperty(id,N'IsTrigger')=1
如果判斷用戶表格的話,用IsUserTable 代替 上面的IsTrigger
函數
select * from sysobjects where id = object_id(N'[dbo].[USER_Fun]') and (type = 'FN' or type = 'TF'))
--判斷是否存在USER_Fun這個用戶函數(注意此處的type 有兩種,分別是'TF'-Table-valued Function 表值函數 或'FN'-Scalar-valued Function 標量值函數)