How to Insert XML Data into Existing XML Node?

 Posted by Lakhangarg on 9/16/2009 | Category: Sql Server Interview questions | Views: 5329
Answer:

declare @xml xml
set @xml = '<root/>'
select @xml

declare @value varchar(10)
set @value = 'val1'
set @xml.modify('insert <item value="{sql:variable("@value")}" /> into (/root)[1]')
select @xml


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response