xml modify

  • I need to update a specific value of a node in an xml column. Im trying to use the replace option of 'modify' but cant figure out the exact syntax.

    heres what i want to replace

    <Catalogue Name="UKArtists" Version="1" />

    I want to set the version to "2" for all the rows in the table for the xml column 'CatalogueXML'

    (this contains the xml)

    heres what ive got

    UPDATE

    dbo.Catalogues

    SET

    CatalogueXML.modify('replace value of (/Catalogue/Version) with "2"')

    anyone got any pointers ?

  • This was removed by the editor as SPAM

  • Im going to be specifying the version in a variable (Ill build a stored procedure because its to be run from within a .net app), so Ive now got this

    DECLARE @Ver VARCHAR(1)

    SET @Ver = '2'

    UPDATE dbo.Catalogues

    SET CatalogueXML.modify('replace value of (/Catalogue/@Version)[1] with ( sql:variable("@Ver") )')

    but it didnt update anything

    I got a message

    348 row(s) affected

    but the version is still the same

  • ok, got it to work, the node is actually underneath a root node which id left out

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply