SQL判断表或存储过程是否存在,若存在则删除然后重新创建

来源:互联网 发布:ios存照片软件 编辑:程序博客网 时间:2024/05/28 18:44

存储过程

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[你的存储过程名]') and OBJECTPROPERTY(id, N'IsProcedure')=1)
drop procedure [dbo].你的存储过程名
go
create procedure [dbo].你的存储过程名
as
begin

//你要干的事
end
go

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[你的表名]') and OBJECTPROPERTY(id, N'IsTable')=1)
drop table[dbo].你的表名
go
create table [dbo].你的表名
go

 

 

 

原创粉丝点击