declare @ID int select @ID=ID from Organization where OStatus = 1--现在我要对找出来的ID执行相同存储过程EXEC proc_name @ID
declare @s nvarchar(4000) set @s='' select @s=@s+'EXEC proc_name '+rtrim(ID)+'; ' from Organization where OStatus = 1 exec (@s)多结果集是这样用
我觉得是用油标来做. declare @id int; declare cur cursor fast_forward for select ID from Organization where OStatus = 1; open cur; fetch next from cur into @id; while @@fetch_status=0 begin EXEC proc_name @id fetch next from cur into @id; end close cur; deallocate cur;
vfp: select ID from Organization where OStatus = 1 into cursor tt use tt scan endscan猜想sql用游标。
select @ID=ID from Organization where OStatus = 1--现在我要对找出来的ID执行相同存储过程EXEC proc_name @ID
set @s=''
select @s=@s+'EXEC proc_name '+rtrim(ID)+'; ' from Organization where OStatus = 1
exec (@s)多结果集是这样用
declare @id int;
declare cur cursor fast_forward for
select ID from Organization where OStatus = 1;
open cur;
fetch next from cur into @id;
while @@fetch_status=0
begin
EXEC proc_name @id
fetch next from cur into @id;
end
close cur;
deallocate cur;
select ID from Organization where OStatus = 1 into cursor tt
use tt
scan
endscan猜想sql用游标。