日期:2014-05-18  浏览次数:20530 次

while里面不能执行存储过程该如何调整
下面的红色部分写法不对,哪位大侠帮忙修改下

两个存储过程各返回1个int值

while

exec a = exec b

begin
select * from tb
end

------解决方案--------------------
SQL code

--給你個基礎例子
if object_id('fn_a') is not null drop function dbo.fn_a;
if object_id('proc_a') is not null drop procedure proc_a;
if object_id('proc_test') is not null drop procedure proc_test;
go
create function dbo.fn_a()
returns int
as
begin
  return 1
end
go

create proc proc_a
@t int output
as
select @t=1;
go
create proc proc_test
as
declare @a int;
exec proc_a @a output;
select @a
if @a=dbo.fn_a()
print 1
else 
print 2;
go
exec proc_test;

------解决方案--------------------
判断两列内容完全一样吗?
不是你这么写的

还有你把整个过程都写到exec 里面就可以了