You must Sign In to post a response.
  • Category: SQL Server

    Importing xml file to table in sql server

    I have a database and contains a table that has varbinary column.
    I am inserting filetype .repx into it. It works fine.

    Then I am exporting the table data to xml.
    I need to import this xml data to same table in a different database.
    but I am getting issues with import.
    When I got it imported, the file is not opening .
    It has got binary data starting with 0x2 in the first database.
    In the second database, it is starting with 0x4.

    Please help. Its urgent,

    How to import in right format ?
  • #764350
    Hi Preethu,
    Their may be the chances that the XML file gets currupted. If possible then please let us know is their any error message you are getting while opening the file?
    You can go through following links for more detailed knowledge about how to import an XML in SQL in proper way.

    Hope it helps.
    Shashikant Gurav

  • #764352
    I don't think your binary data will be properly exported to xml. Data loss/change possibility is more here.
    If you want to export data and import in another database table then you can directly use INSERT INTO...SELECT Query
    see below syntax
    INSERT INTO DB1.dbo.table_name
    SELECT * FROM DB2.dbo.table_name
    WHERE column_name NOT IN
    SELECT column_name FROM DB1.dbo.table_name

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764389
    You can use given code snippet as guideline to Importing xml file to table in sql server
    Select Convert(XML, BColumn) AS RawXml 
    FROM OPENROWSET(BULK 'D:\MyExampleData.xml', S_BLOB) AS MRowSetName

    I recommended few URL for your questions

Sign In to post your comments