dbTalk Databases Forums  

Export table to xml file using DTS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Export table to xml file using DTS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
denis
 
Posts: n/a

Default Export table to xml file using DTS - 10-08-2003 , 05:38 AM






SQL Server 2000
I'm using the code listed below to export a table to an xml file but the
resulting xml is not structured as I need

The code writes the following xml structure
<ROOT>
<Prova field1="xx" field2="yy"...>
<Prova field1="xx" field2="yy"...>
</ROOT>

But I need the following

<ROOT>
<ROW value=1>
<FIELD1>xx</FIELD1>
<FIELD2>yy</FIELD2>
</ROW>
<ROW value=2>
<FIELD1>xx</FIELD1>
<FIELD2>yy</FIELD2>
</ROW>
</ROOT>

Do you have any suggestions?
Thanks


This is the script I'm using
'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

Dim oCmd, sSQL, oDom

''' If MSXML 4.0 is not installed this will not work!
Set oDom = CreateObject("Microsoft.XMLDOM")

Set oCmd = CreateObject("ADODB.Command")
oCmd.ActiveConnection =
"PROVIDER=SQLOLEDB;SERVER=sql.intra.net;UID=sa;PWD =login4sa;DATABASE=Chelab;
"

sSQL = "<ROOT xmlns:sql='urn:schemas-microsoft-com:xml-sql'><sql:query>"
& _
"select * from prova for xml auto</sql:query></ROOT>"

oCmd.CommandText = sSQL
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"

oCmd.Properties("Output Stream") = oDom
oCmd.Execute , , 1024

oDom.Save "c:\denis.xml"

Main = DTSTaskExecResult_Success

End Function



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.