Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help learning how to export data from SQL in XML form and then importing that data back into SQL. I am using the AdventureWorks2016

Need help learning how to export data from SQL in XML form and then importing that data back into SQL. I am using the AdventureWorks2016 data downloaded from

https://www.microsoft.com/en-us/download/details.aspx?id=49502

This is my code so far for exporting:

SELECT * FROM Person.Person WHERE FirstName = 'John'; 

Then I clicked the link to view the data as XML. Then I right clicked the query tab and selected "save as" and saved it as "xmlTest.xml".

So now.. trying to import it back into sql and this is my code so far:

DECLARE @xmlTest XML; DECLARE @hdoc int; SELECT @xmlTest = xml_test FROM OPENROWSET(BULK '', SINGLE_BLOB) x; EXEC sp_xml_preparedocument @hdoc OUTPUT, @xmlTest; exec sp_xml_removedocument @hdoc; 

I got an error saying that I had to change xml_test to xmlTest, and after I did it return a message stating that my "Commands completed successfully" but i thought it would bring up the data I am trying to import in a table form. Any ideas and what I am doing wrong?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions