判断 函数 存储过程 用法
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[test1]'))begin select 1 create table test1(id int)end goif not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[test]'))begin create proc test(@p_id int ) as begin select 3 end end go
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[test]')) drop proc testgocreate proc test(@p_id int )asbegin select 3end go