Solved

BCP Utility with XML Data Type

Posted on 2013-06-25
4
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 27

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 27

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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

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 …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 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