有表table1,过程proc1
如何把table1中的field1,field2赋给proc1中的@a,@b?不知这个循环语句如何写.感谢!!!----select field1,field2 from table1
----exec proc1 @a=field1,@b=field2

解决方案 »

  1.   

    有表table1,过程proc1
    如何把table1中的field1,field2赋给proc1中的@a,@b?不知这个循环语句如何写.感谢!!!----select field1,field2 from table1
    ----exec proc1 @a=field1,@b=field2
    ------------------------------------------
    没看明白,field1,field2是两个字段吗,循环语句?
      

  2.   

    declare @a ?类型, @b ?类型
    declare curTest cursor for select field1,field2 from table1
    open curTest
    fetch next from curTest into @a,@b
    while @@fetch_status = 0
    begin
    exec proc1 @a,@b
    fetch next from curTest into @a,@b
    end
    close curTest
    deallocate curTest