Solved

BCP Utility with XML Data Type

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now