如:在存储过程中
写了这样的sql语句:set @sql=select * from Ebasic_other exec(@sql)
然后我想有没有类似dt.Rows[i].pricetype的方法直接在存储过程里面取得sql结果集的某行某列的值啊?

解决方案 »

  1.   

    楼主的语法...
    把结果集 into 到临时表或都表型变量里就可以那样做了.
      

  2.   

    --例子
    create table t(id int , c1 varchar(10),c2 varchar(20))
    go
    insert t
    select 1,'a1','a2'
    union all
    select 2,'b1','b2'
    union all
    select 3,'c1','c2'
    union all
    select 4,'d1','d2'
    gocreate proc p(@row_value int,@column_name varchar(10))
    as
    begin
         declare @str varchar(1000)
         
         select @str='select top 1 '+@column_name+' from (select top '+str(@row_value)+' * from t order by id) a order by id desc'
         exec(@str)
    endgop 2,'c2'
    go
    p 3,'c1'drop table t
    drop proc p
      

  3.   

    TO: leo_lesley 
    select * from glass_GetBoms_amt(@prd_no) where pro_type='bomsm'
    while (@@RowCount>0)
    如果@@RowCount=5,我想通过while循环来获取某的字段的全部五行的值,怎么弄?