具体问题是 我要在一个存储过程中 获取另一个存储过程的返回值和输出参数假如有一个这样的存储过程create proc aaaa
@a int ,
@return int out
select * from a where a.id=@a
set @return='输入参数'
return 0另一个存储过程create proc bb
as
exec @a =[aaaa]
这样可以获取到返回值 ... 可怎么获取输入参数呢?
@a int ,
@return int out
select * from a where a.id=@a
set @return='输入参数'
return 0另一个存储过程create proc bb
as
exec @a =[aaaa]
这样可以获取到返回值 ... 可怎么获取输入参数呢?
go
Create table a(ID int identity,num int)
insert a select 10
insert a select 20
gocreate proc aaaa
@a int ,
@return nvarchar(100) out
as
select * from a where a.id=@a
set @return='输入参数'
goCreate proc bb
as
begin
declare @return nvarchar(100)--接收返回值 Declare @T table(ID int,Num int)--接收返回结果集 insert @T exec [aaaa] @a=1,@return=@return out select @return as 返回值--返回值 select * from @T--返回结果end
go
exec bb
/*
返回值ID Num
1 10
*/
谢谢 问题已经解决了....
我还想问一个问题 ,那就死 if 语句 里还可以嵌套if语句么 我用了好像会出错呢?
if
begin
if....
if....
if
begin
.....
end
end
这样会报错的 好像sqlserver 中有一个关键字 可以在 if里处理批量语句吧.. 只要把那批量语句用个关键字 "圈"起来.. 麻烦解释下
set @i=4if @i=1
select 1
else if @i=2
select 2
else if @i=3
select 3
else
select 4
goif 中再 ifdeclare @i int
set @i=3if @i>1
begin
if @i<2
select 1
else
select 3
end
else
select 1
begin
if ...
begin
两个及以上语句需要使用begin end
end
else
如果只有一个语句,则可以省略begin end
end
else
begin
if
else
end
当然可以 注意IF的对应和BEGIN...END的对应就可以了