-- 判斷要創(chuàng)建的存儲過程名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[存儲過程名]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
-- 刪除存儲過程
drop procedure [dbo].[存儲過程名]
GO
-- 判斷要創(chuàng)建的視圖名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[視圖名]') and OBJECTPROPERTY(id, N'IsView') = 1)
-- 刪除視圖
drop view [dbo].[視圖名]
GO
-- 判斷要創(chuàng)建的函數(shù)名是否存在
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[函數(shù)名]') and xtype in (N'FN', N'IF', N'TF'))
-- 刪除函數(shù)
drop function [dbo].[函數(shù)名]
GO
if col_length('表名', '列名') is null
print '不存在'
select 1 from sysobjects where id in (select id from syscolumns where name='列名') and name='表名'