?
Solved

BCP Utility with XML Data Type

Posted on 2013-06-25
4
Medium Priority
?
371 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

771 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