存储过程中如何设置返回值,另外一个存储过程又如何调用该返回值,详情请看。。。
--说明:这个存储过程中查询出xhbh字段的值(可能为0、1、或者多个)然后返回给pro2做为xxflbh in()括号内的条件
--比如执行完pro1后结果如下:
xhbh
106D96C39BDca1C72349
1065283BDB690F98317C
105C75EBFC636109F0BD
那么在pro2中调用pro1返回的结果后组成的sql语句应该是这样的:
delete from bd_sbsxbjg where cjbh=(select cjbh from bd_zzcj where cjmc=@param1)
and xxflbh in('106D96C39BDca1C72349','1065283BDB690F98317C','105C75EBFC636109F0BD')
--有返回值的存储过程
create procedure pro1
@param1 varchar(100),@param2 varchar(100)
as
select xhbh from bd_sccjxh
where tname in(select tname from bd_sccjxh where cjbh=(select cjbh from bd_zzcj where cjmc = @param1)
and xhbh in(select xhbh from bd_sccjxh where cjbh=(select cjbh from bd_zzcj where cjmc = @param2))
and xhbh in(select xhbh from bd_sccjxh where cjbh=(select cjbh from bd_zzcj where cjmc = @param1)))
GO
--调用存储过程pro1
CREATE procedure pro2
@param1 varchar(100),@param2 varchar(100)
as
delete from bd_sbsxbjg where cjbh=(select cjbh from bd_zzcj where cjmc=@param1)
and xxflbh in()
不知道问题是否已经说明白