我要从Sell_Item表里读取订单sellID=123的物资和相关订单号(字符型)记录,然后再调用另一个存储过程重新统计每个物资的库存。订单的状态,请问该怎么写?
大致思路如下,请帮忙解决如何循环。
select itemid,LinkNum from [Sell_Item] where sellid=123
do while not rs.eof
  Exec Stat_item @itemID
  Exec Stat_LinkNum @LinkNum
loop只读取一个字段的方法知道了,读取2个字段要怎么写?呵呵。

解决方案 »

  1.   

    declare @itemId int
    declare @linknum int
    declare cur cursor for 
           select itemid,LinkNum from [Sell_Item] where sellid=123
    open cur
    fetch next from cur into @itemid,@linknum
    while(@@fetch_status = 0)
    begin
        Exec Stat_item @itemID
        Exec Stat_LinkNum @LinkNum
        fetch next from cur into @itemid , @linknum
    endclose cur
    deallocate cur
    -------------------t-sql循环记录要用游标来进行,你那是既有asp,又有 t-sql