I am trying to calculate the CRC of a xml file and write it to xml as
the attribute
of the end element.
Thanks in advance
Bhavana
DECLARE @xml XML, @i INT
SET @xml = '<root><element1></element1><element2></element2></root>'
SET @i = 2
SELECT 'before', @xml
-- Add attribute to root node
SET @xml.modify('insert attribute records {sql:variable("@i")} into root[1]')
SELECT 'after', @xml
If this does not work for you, can you provide a small sample of what your
XML looks like before and your expected results?
HTH
wBob
SET @xml.modify('insert attribute records {sql:variable("@i")} into
(//*[last()])[1]')