Export XML from ms sql 2008

  • Thread starter Thread starter Eric S
  • Start date Start date
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
 
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! |
*******************************************
 
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! |
*******************************************
 
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
 
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! |
*******************************************
 
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! |
*******************************************
 
Back
Top