XML : Update a field from a xml column in SQL Server

update CUSTOMER_ORDER_RESERVATION_DETAIL

set trans_batch_no =

(

select distinct x.h.value(‘@trans_batch_no’, ‘nvarchar(40)’) as trans_batch_no

from o.customer_order_detail.nodes(‘/business_object/header/lists/row’) x(h)

)

from CUSTOMER_ORDER_RESERVATION_DETAIL f

join CUSTOMER_ORDERS o on f.order_number = o.order_number

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s