BCP with xml

  • Hello All

    Sql Server 2008 SP 2:

    We have a table abc_xml which has def_xml col with varbinary in which we are storing .xml files

    we use the below command to extact the .xml file using bcp

    declare @cmd varchar(8000)

    Set @cmd ='bcp "select cast(def_xml as varchar(2000)) from abc_xml" queryout d:\ppt.xml -t -w -r "" -S Abasha -U xxx -P xxx'

    PRint @cmd

    exec master..xp_cmdshell @cmd

    we are able to genrate th xml file.

    But when we try to open the .xml file in browser we are gettin the below error.

    The XML page cannot be displayed

    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.

    Switch from current encoding to specified encoding not supported. Error processing resource 'file:///D:/ppt.xml'. Line 1, ...

    <?xml version="1.0" encoding="utf-8"?>

    Please suggest how to solve.

    Thnaks in advance

  • I copied the error message "Switch from current encoding to specified encoding not supported." into google.

    The very first link returned: "You get this error if your XML file was saved as double-byte Unicode (or UTF-16) with a single-byte encoding (Windows-1252, ISO-8859-1, UTF-8) specified."

    You're using bcp -w.

    As per BOL: -w: Performs the bulk copy operation using Unicode characters.

    Seems obvious to me....



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • yes... -w didnt work either.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply