Solved

BCP Utility with XML Data Type

Posted on 2013-06-25
4
365 Views
Last Modified: 2013-07-02
I am attempting to export data from a table with a single column of type XML. I am using the command:
bcp mydatabase.dbo.XMLMinedData out C:\ConfigurationData.xml -N -T -S localhost
based on comments at http://msdn.microsoft.com/en-us/library/ms191184.aspx. The file that is created looks like a bunch of Chinese when I open it in any editor.
The table contains a single column named Data. The datatype is XML. I want to create an XML file from this data.
The data is formatted as:
<ROOT>
  <Address>
    <row ID="1" StreetAddress1="7701 WALNUT ST" StreetAddress2="SUITE 150" City="Los Angeles" CountyID="164" ctStateID="12" ZipCode="94183" Latitude="41.2316320" Longitude="-84.6450690" />
  </Address>
  <Algorithm>
    <row ID="1" ctAlgorithmDomainID="1" Name="Refund Calc" AlgorithmDisplay="Refund Algorithm" IsDeleted="0" />
  </Algorithm>
  <Role>
    <row ID="1" Name="System Administrator" IsActive="1" IsStaffRole="1" />
    <row ID="2" Name="Security Admin" IsActive="1" IsStaffRole="1" />
    <row ID="3" Name="CPA" IsActive="1" IsStaffRole="0" />
    <row ID="4" Name="Finance Manager" IsActive="1" IsStaffRole="1" />
   <row ID="5" Name="Scheduler" IsActive="1" IsStaffRole="0" />
   <row ID="6" Name="Operations Manager" IsActive="1" IsStaffRole="0" />
   <row ID="7" Name="Investigator" IsActive="1" IsStaffRole="1" />
  </Role>
</ROOT>

Open in new window

0
Comment
Question by:dbbishop
  • 2
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
Zberteoc earned 500 total points
ID: 39275566
Try this:

bcp mydatabase.dbo.XMLMinedData out C:\ConfigurationData.xml -c -T -S localhost
0
 
LVL 15

Author Comment

by:dbbishop
ID: 39275781
Okay, that appears to work. I am going to try to process the file that it created. My question though (because inquiring minds want to know) is, why did MSDN specify to use -N if it results in unreadable data? Did they have something else in mind.
0
 
LVL 26

Expert Comment

by:Zberteoc
ID: 39275839
Probably because that example produces a result that is not for human eyes but just to move the content to another server to be imported with the same parameter, -N, maybe is faster that way.
0
 
LVL 15

Author Closing Comment

by:dbbishop
ID: 39294351
Thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question