How to import from XML file in SQL Server Import and Export Wizard?

finch picture finch · Mar 9, 2014 · Viewed 7k times · Source

I have data and schema for a table as a single XML file. How do I import this using the SQL Server Import and Export Wizard?

Should I use a "Flat File Source" as my Data Source? Or what?

[For info, I exported the XML from VistaDB, but I have not yet got as far as the point where the system which created the data might be an issue.]

Answer

Karl Kieninger picture Karl Kieninger · Mar 10, 2014

As far as I know, you cannot do this by using a the import export wizard. Assuming you want the data to wind up all relational rather than as XML datatype, you'll need to create the table and use sp_xml_preparedocument and OPENXML.

See How to use OPENXML to load XML data into existing SQL Table?