当前位置: 代码迷 >> Sql Server >> SQL中怎么提取查询出的结果
  详细解决方案

SQL中怎么提取查询出的结果

热度:21   发布时间:2016-04-27 15:03:40.0
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) > 1declare @i intset @i=1while exists(select 1 from # where id<[email protected])begin    exec Pro_GetInvPrice (select spdm from # where [email protected])    set @[email protected]+1end
  相关解决方案