i have following code update records in miitem works fine, how can use data table called [wi] dynamically
use db1; go update miitem set [fldxml]= '<fields> <field5>use disc:300230 formed od:13.48 bh spec:8/8/6.003, bh size: 0.656, c/s spec: 90/0.843/conical 2</field5> <field6>1 - cl thru plate-v/s hole size:5/8"z1 v:0.125 l:0.125 color:100270 agc reverse disc</field6> <field7>n/a</field7> </fields>' [itemid]='500201'
here data looks in source table
here data looks in application
here record in miitem or destination table
i want replace text
use disc:300230 formed od:13.48 bh spec:8/8/6.003, bh size: 0.656, c/s spec: 90/0.843/conical 2
value in [wi].[disc_note] field in [wi] table dynamicallyi want replace
1 - cl thru plate-v/s hole size:5/8"z1 v:0.125 l:0.125 color:100270 agc reverse disc
value [wi].[wheel_note] field dynamicallyi want replace
n/a
[wi].[assembly_note] field [wi] table. go between field dynamically
you can use tsql xml dml purpose (assuming fldxml
xml
data type). query looks this.
update miitem set [fldxml].modify('replace value of (fields/field5)[1] sql:column("disc_note")') miitem m inner join wi on m.idemid=wi.stock_id --where m.idemid='500201' --if need
note have run update
trice (separately each field5, field6 , field7) because xml dml doesn't allow multiple node update.
update
if fldxml
string need compare overhead between building whole string
fldxml='<fields><field5>'+wi.disc_note+...
and creating temporary table.
declare @miitem table (itemid int, fldxml xml) insert @miitem (itemid, fldxml) miitem --where... if need
then update @miitem
several times each node according initial answer ,
update miitem set [fldxml]=x.fldxml miitem t inner join @miitem x on t.itemid = x.itemid
Comments
Post a Comment