Microsoft SQL Server – export XML column rows from SQL table into individual files

   Microsoft SQL Server – export XML column rows from SQL table into individual files

It is roughly formatted as such

+————–+——————+
| REFERENCE_ID | REFERENCE_XML |
+————–+——————+
| 1 | <xml>…</xml> |
| 2 | <xml>…</xml> |
| 3 | <xml>…</xml> |
| 4 | <xml>…</xml> |
| … | <xml>…</xml> |
| 70000 | <xml>…</xml> |
+————–+——————+

I would like to loop through every row and bulk export each REFERENCE_XML column and name it as the REFERENCE_ID

My output folder set would look as such

C:\References\1.xml
C:\References\2.xml
C:\References\3.xml
C:\References\4.xml
C:\References\…
C:\References\70000.xml

Leave a Reply

You must be logged in to post a comment.