update sql table xml column with xml of each row
All I want is to update rowXml column as shown below so that table
contains xml for > each row.
`Declare @tbl table (id int, name varchar(50), rowXml xml)
insert into @tbl (id, name)
values (1,'A'), (2, 'B'), (3,'C'),(4,'D')
Select * from @tbl
update @tbl set rowXml = '<row><id>1</id><name>A</name> </row>' where id = 1
update @tbl set rowXml = '<row><id>2</id><name>B</name> </row>' where id = 2
update @tbl set rowXml = '<row><id>3</id><name>C</name> </row>' where id = 3
update @tbl set rowXml = '<row><id>4</id><name>D</name> </row>' where id = 4
Select * from @tbl
`
What I want as output is the output from @tbl. I know that there is a lot
of xml support in sql server 2008 r2, just want to know the most efficient
way to achieve this
No comments:
Post a Comment