Question

Is there a way to unite the following statements:

UPDATE @Test
SET [XML].modify('delete (Settings/@attributefordeletion1)[1]')

UPDATE @Test
SET [XML].modify('delete (Settings/@attributefordeletion2)[1]')

UPDATE @Test
SET [XML].modify('delete (Settings/@attributefordeletion3)[1]')
Was it helpful?

Solution

update @Test
set [XML].modify('delete (
                         Settings/@attributefordeletion1, 
                         Settings/@attributefordeletion2, 
                         Settings/@attributefordeletion3
                         )')

Or if you want to delete all attributes

update @Test
set [XML].modify('delete Settings/@*')

OTHER TIPS

Found out one more way to delete set of attributes:

update @Test
set [XML].modify('delete Settings/@*[local-name()=(
                                    "attributefordeletion1",
                                    "attributefordeletion2", 
                                    "attributefordeletion3"
                                    ]')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top