Solved

BCP Utility with XML Data Type

Posted on 2013-06-25
4
363 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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