--建立处理游标
declare sub_order_cur cursor for
select tbSub_Order.stock_no ,unit_price ,order_quantity ,unit ,order_remark ,stockreceive_remark ,order_amount
from tbSub_Order
inner join tbMaster on tbMaster.stock_no=tbSub_Order.stock_no
where location_id=@location_id and order_no =@order_no and status not in (3,5,6)
open sub_order_cur
fetch next from sub_order_cur into @stock_no,@unit_price ,@order_quantity,@unit,@order_remark,@stockreceive_remark ,@order_amount
while @@fetch_status=0
begin
insert into OPENDATASOURCE('SQLOLEDB','Data Source=10.200.253.25;User Id=SMSLinkuser;Password=SMS@link*2012%^&') .AIS20120531133013.dbo.t_ZDF_SynPOOrderEntry
values (@FUUID ,@stock_no ,@unit_price,@order_quantity ,@unit ,@order_remark ,@stockreceive_remark,@order_amount )
fetch next from sub_order_cur into @stock_no,@unit_price ,@order_quantity,@unit,@order_remark,@stockreceive_remark ,@order_amount
end
close sub_order_cur
deallocate sub_order_cur