Export XML from ms sql 2008

E

Eric S

Hi All,

Any idea how to export an xml documnet from ms sql 2008 using vb.net into a
folder some where? I am running an SP that generates the xml already.

Thanks,

Eric
 
G

Gregory A. Beamer

Any idea how to export an xml documnet from ms sql 2008 using vb.net
into a folder some where? I am running an SP that generates the xml
already.

I would offer something different than Mark:

http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx


NOTE that this assumes you are getting a full XML document, with root tags,
rather than an XML snippet. SQL Server can do both.

peace and grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
G

Gregory A. Beamer

I took from the OP that he had already fetched a well-formed XML
document from SQL Server and simply wanted to know how to save it do
disk...

I am a bit TOO XML oriented in many cases. LOL

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
E

Eric S

Hi Gregory,

Thanks for your reply. Do you know of any sample somewhere?
Another problem is when I ran the SP within the MS SQL 2008 it generates the
XML as a fine file.

Running the below code somehow I am getting an error like this: Invalid at
the top level of the document. Error processing. When tryuing to see the
value of the cmd.CommanText.
But this is an OK file which already used all the time. (Copy and paste from
the ms sql server).

Dim cmd As New SqlCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "dbo.XML_MenuOptions"

Using ProductWriter As XmlWriter = XmlWriter.Create(cmd.CommandText)

End Using

Thanks,

Eric
 
G

Gregory A. Beamer

Thanks for your reply. Do you know of any sample somewhere?

After having a "discussion" with Mark, I think this might answer your
question:
http://tinyurl.com/y9trqjr

It is a very simple save to a file from SQL Server XML kind of answer. As
you know you are dealing with valid XML, the addition of the XML classes is
probably overkill.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
E

Eric S

Thanks Gregory

Gregory A. Beamer said:
After having a "discussion" with Mark, I think this might answer your
question:
http://tinyurl.com/y9trqjr

It is a very simple save to a file from SQL Server XML kind of answer. As
you know you are dealing with valid XML, the addition of the XML classes
is
probably overkill.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top