You are here: Need help with Importing XML data to a table « MsSQL Server « IT news, forums, messages
Need help with Importing XML data to a table

Posted by serge on 07/14/05 05:36

Using some VB sample code on the Internet I have the following
that works well and exports a set of records to an XML file:

Dim oCmd, sSQL, oDom

Set oDom = CreateObject("Msxml2.DOMDocument.4.0")

Set oCmd = CreateObject("ADODB.Command")
oCmd.ActiveConnection = "Provider=SQLOLEDB;Data Source=(local);Initial
Catalog=TestXML;UID=sa;Password=123456"

sSQL = "<ROOT
xmlns:sql=""urn:schemas-microsoft-com:xml-sql""><sql:query>" & "select *
from tblTest 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:\temp\testdts.xml"


This is my first day of using XML in SQL Server and I need help on how
to imitate INSERT statements by basically importing data from an xml file.

With some changes I managed to write VB code that seems to be reading
the XML file I exported earlier but I can't seem to know what to do to be
able to take the data only of the XML and INSERT it into a table.
The code I used is the one found in the SQL Online Help, search in INDEX
for "OPENXML" and then choose "USING OPENXML"

If you have sample code or can point me to a link that has sample code to
achieve what I want, I would appreciate your help.

Thank you

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация