Skip to content
Advertisement

Update multiple XML nodes in single Update SQL statement

I want to update multiple XML nodes in single Update query

XML:

This is what I have tried:

It works only for single Update, if I use more then one like ValueType and TransactionId, it shows an error. Please help me – how to update this?

Msg 264, Level 16, State 1, Line 7
The column name ‘TransmissionData’ is specified more than once in the SET clause or column list of an INSERT. A column cannot be assigned more than one value in the same clause. Modify the clause to make sure that a column is updated only once. If this statement updates or inserts columns into a view, column aliasing can conceal the duplication in your code.

Advertisement

Answer

Please try the following solution.

It is using XQuery and its FLWOR expression.

It will update XML elements in question, leaving everything else intact.

I had to fix the input XML to make it well-formed.

SQL

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement