Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Kumar_Anil
Yak Posting Veteran
68 Posts |
Posted - 2008-05-08 : 13:43:23
|
This is a run of the mill application that moves orders from one table to another. There are 2 tables, Ordersummary & HstOrders.Ordersummary has the following columns...IdentifierFollowupIdOrderNumberOrderReferenceOrderReferenceOrigin............HstOrders has the following columns...IdentifierOrderNumberOrderReferenceOrderType............The above two tables are bound by Identifier. After each month end, Orders are moved from Ordersummary to HstOrders. Now my task is to update all rows in OrderSummary with the order details as seen in HSTOrders for ordertype = 'CREDIT'. OrderReferenceOrigin(in Ordersummary) should be updated with the value of Orderreference(from hstorders). I have to update each row at a time & I need to write a cursor for mass updates where ordersummary.identifier = hstorders.identifier.Can someone please help with in writing this update statement as I never wrote a cursor. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-08 : 13:50:08
|
Why do you want a cursor? Any specific reason why you dont use a set based soln?Update oSET o.OrderReferenceOrigin=h.OrderReference.....other fieldsFROM OrderSummary oINNER JOIN HstOrders hON h.OrderNumber=o.OrderNumberWHERE h.OrderType='CREDIT' |
|
|
|
|
|