Search code examples
sql-serverxmldatabaseimportbcp

Import XML with BCP into SQL Server


This code not import the whole xml file contents, but only a part.

bcp s1.dbo.table_test in myfile.xml -c -T -S localhost\sqlexpress

My file is a large file, around 100 MB and my table has the xml column

How to solve this? Thank you


Solution

  • As pointed out in the comments, I assume, that your XML was read completely. Storing data within an XML column is impossible, if the XML is not valid...

    You might try:

    SELECT DATALENGTH(YourXMLColumn) FROM YourTable 
    

    and see the used bytes (attention: its unicode, two bytes per char).

    Or Try

    SELECT LEN(CAST(YourXML AS VARCHAR(MAX))) FROM YourTable
    

    returns the count of characters

    Or

    • right click into your query
    • go to the options
    • find the options for the data grid
    • set the XML size to unlimited

    Hope this helps