if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[test1]'))
begin
select 1
create table test1(id int)
end
go
if 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上述代码创建表的时候没有问题,但是创建存储过程的时候却报错“消息 156,级别 15,状态 1,第 4 行
关键字 'proc' 附近有语法错误。”存储过程的代码为什么只能这样写
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[test]'))
drop proc test
go
create proc test(@p_id int )
as
begin
select 3
end
go
begin
select 1
create table test1(id int)
end
go
if 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上述代码创建表的时候没有问题,但是创建存储过程的时候却报错“消息 156,级别 15,状态 1,第 4 行
关键字 'proc' 附近有语法错误。”存储过程的代码为什么只能这样写
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[test]'))
drop proc test
go
create proc test(@p_id int )
as
begin
select 3
end
go
DROP PROCEDURE xx打开一个存储过程,右键 编写脚本,drop create到新窗口,你就可以看到删除语句了。
其它的函数,一样的。
begin
exec('
create proc test(@p_id int )
as
begin
select 3
end
')
end