XML columns compare in SQL Server -


i have got 3 columns:

  1. [oldcontent] [xml] null
  2. [newcontent] [xml] null
  3. [oldcontent] [xml] null

i want compare data in 2 columns. want write results third column ([oldcontent])

how can in sql server?

[oldcontent] [xml] null, in

value

<row guest_id="13" guest_name="vedat" guest_surname="pala" adress="izmir" /> 

[newcontent] [xml] null, in value

<row guest_id="13" guest_name="vedat35" guest_surname="pala" adress="izmir" city="dr" city_code="35" /> 

i want write value in it.

[updatecontent] [xml] null  <row guest_name="vedat35 city="dr" city_code="35" /> 

i need procedure compare xml column values.

http://i57.tinypic.com/2pqky80.jpg

http://i60.tinypic.com/2cpc615.jpg

it quite easy data out of xml. may compare data "as ever". result can write out new xml "for xml".

try this:

declare @myxml xml= '<rows>  <row guest_id="13" guest_name="vedat35" guest_surname="pala" adress="izmir" city="dr" city_code="35" />  <row guest_id="14" guest_name="testguestname" guest_surname="testsurname" adress="testaddr" city="testcity" city_code="11" />  </rows>';  --this how retrieve data  select x.y.value('@guest_id','int')       ,x.y.value('@guest_name','varchar(max)')       ,x.y.value('@guest_surname','varchar(max)')       ,x.y.value('@adress','varchar(max)')       ,x.y.value('@city','varchar(max)')       ,x.y.value('@city_code','int') @myxml.nodes('/rows/row') x(y)  --this how create new xml data select 13 [@guest_id]       ,'newname' [@guest_name]       ,'newsurname' [@guest_surname]             ,'newaddr' [@guest_adress]             ,'newcity' [@city]       ,12 [@city_code] xml path('row'),root('rows')  

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -