--方法一
declare SailsReport_cursor cursor
for
select ets.OrderId,et.FillOrder_Time from ET_Order et
inner join ET_Order_SailsReport ets
on et.pkid=ets.OrderID
declare @OrderId int, @FillOrder_Time datetime
open SailsReport_cursor
fetch next from SailsReport_cursor
into @OrderId,@FillOrder_Time
while ( @@Fetch_Status=0 )
begin
update ET_Order_SailsReport set FillOrder_Time=@FillOrder_Time
where orderid=@OrderId
fetch next from SailsReport_cursor
into @OrderId,@FillOrder_Time
end
close SailsReport_cursor
deallocate SailsReport_cursor


--方法二
update ET_Order_SailsReport
set FillOrder_Time = et.FillOrder_Time
from ET_Order_SailsReport ets
left outer join et_order et on et.pkid=ets.OrderID

--测试语句
--SELECT PKID, Pay_Type, FillOrder_Time FROM ET_Order WHERE (PKID IN (89515, 89503, 89394, 88061)) ORDER BY PKID DESC
--select OrderID,FillOrder_Time from ET_Order_SailsReport order by orderid
posted on 2011-09-06 22:38  小伟地方  阅读(147)  评论(0编辑  收藏  举报