May 3, 2016 at 9:49 pm
Hi,
I am trying to export an xml column into a text file using the below mix of powershell and TSQL:
$Srv = 'MySqlServer\myinstance'
$bcpconn = '-T'
$Query = '"select top 100 SomeXmlColumn from MyDB.dbo.MyTable"'
$Saveas = 'C:\temp\Export\MyTable_20160504_xml_short.xml'
bcp $Query QUERYOUT $Saveas -c -x $bcpconn -S $Srv
However I get every record as a single line. How can I change this to make sure every record has a proper structure in the text file with all line breaks?
Thanks
May 3, 2016 at 11:04 pm
Are you sure the XML's stored in the table contain line breaks?
_____________
Code for TallyGenerator
May 3, 2016 at 11:55 pm
Sergiy (5/3/2016)
Are you sure the XML's stored in the table contain line breaks?
Not sure, but I need a way to somehow transform it, so it has line breaks. Management Studio shows them with line breaks if you output them to grid and click on the column, which proves the transformation is possible.
May 4, 2016 at 5:00 am
Studio has an XML Parser built in it.
This module is responsible for reading, validating and formatting XML strings when you open it for viewing.
It's a front-end application, not any part of SQL Server.
If you really want to apply formatting to saved files then you need to submit them through such a parser.
But really - there is no benefit in doing that. Wasting your time and system resources.
Extra formatting will only slow down XML processing by machine, and for human eye presentation you may use a dedicated application which will apply desired formatting on fly.
_____________
Code for TallyGenerator
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply