Home > database >  Send subtopic SQL SERVER XML value transformation problem
Send subtopic SQL SERVER XML value transformation problem

Time:11-11

Will be how to parse the XML into the value of the following lines show?

 

Declare @ XML XML

Select @ XML='& lt; Event name="sql_batch_completed package"="is essentially" timestamp="2020-07-30 T03:02:57. 197 z" & gt;
0 & lt;/value>

999 & lt;/value>

2 & lt;/value>

3 & lt;/value>

4

5 & lt;/value>

6 & lt;/value>

7 & lt;/value>
OK

Use [master]

8 & lt;/value>

9 & lt;/value>

'

CodePudding user response:

 SELECT STUFF (
(SELECT the ', '+ xmlValue FROM (
SELECT
T.C.V alue (' value [1] 'and' varchar (Max) ') AS xmlValue
The FROM @ XML nodes ('/event/data ') AS T (C)
) t FOR XML PATH (' ')), 1, 1, ' ') AS newValue



Results:
NewValue
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
0999,2,3,4,5,6,7, use [master]

Line (1) affected

  • Related