sql是否存在某存储过程某表某字段

1、是否存在某字段
if not exists(select * from syscolumns where id=object_id('OfficeSupply') and name='OffsPrice')
begin
alter table OfficeSupply add OffsPrice numeric(10, 2) default 0.00
end
go

2、是否存在某存储过程
if(not OBJECT_ID('pr_CreateTable')is null)
begin
  drop proc pr_CreateTable
end
go

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pt_GetProjMColumnFields]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[pt_GetProjMColumnFields]
go

3、是否存在某表
if(not OBJECT_ID('HR_DictCatalog')is null)
begin
 drop table HR_DictCatalog
end
go

 if exists(select name from sysObjects where name='ProjM_BuildProject' and   type = 'U')
drop table [ProjM_BuildProject]


4、某临时表

if object_id('tempdb..#t') is not null
    drop table #t

posted @ 2013-05-20 23:36  Trilyn  阅读(177)  评论(0)    收藏  举报