SQL中如何提取查询出的结果
存储过程中执行到 SELECT SPDM from #tmpJgTbl group by SPDM having count(SPDM) > 1
查询的结果为
SPDM
--------------------
01
02
03
...
如何分别提取出01 ,02 ,和03...
如用用数组之类的去接收查询结果,便于下面的循环使用
exec Pro_GetInvPrice '01'
exec Pro_GetInvPrice '02'
exec Pro_GetInvPrice '03'
..
..
请高手们帮忙看看,解决一下。谢谢了。
------解决方案--------------------难道用游标?
------解决方案--------------------少加个循环变量赋值.......
SQL code
SELECT SPDM,id=identity(int,1,1) into # from #tmpJgTbl group by SPDM having count(SPDM) > 1
declare @i int
set @i=1
while exists(select 1 from # where id<=@i)
begin
exec Pro_GetInvPrice (select spdm from # where id=@i)
set @i=@i+1
end