Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

XML to MS SQL Server

Hi,
    I am using Visual Basic 6.0 and I have incoming XML documents that I want placing in a database. Currently the database is on MS SQL Server, though I may need to change this at a later date.
    I can think of plenty of ways of importing the XML into a database, but I'd like to ask if anyone has an efficient way of doing this.
   
    The current method I'm using is turning XML into an SQL Queries. This means that the query can now be made on any database. I can use either XSL or an object library (currently using XSL) to convert the XML to SQL Queries.
    And then connecting to the MS SQL Server and executing the query.

    Thanks
0
DragonWolf
Asked:
DragonWolf
1 Solution
 
DragonWolfAuthor Commented:
I'm using the MSXML library using the DOM data structure and DOM transformation to implement the XSL on the XML.
0
 
Anthony PerkinsCommented:
If all you want to do is save the XML document in SQL Server than all you need is to write a Stored Procedure and pass the XML document as a parameter or use the Stream object.

Anthony
0
 
mdouganCommented:
If you are using SQL Server 2000 there are a number of efficient alternatives.  The most efficient one I think would be using the new bulk load feature that is available with the Web Release 1 of SQL Server (see the second link below).  There are also queries that you can construct using OpenXML for either selecting data or inserting/updating data (you can also update using the Web Release 1 through "updategrams")

OpenXML
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsql/ac_openxml_1cx8.asp

Web Release 1
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql2k/html/updategrams.asp

A less efficient approach, depending on the format of your XML, is that you could probably load it into a disconnected recordset using the Recordset.Load (or is that Recordset.Read?) command, and providing the XML file (or DOM Object).  Then, you might be able set an active connection and do an .UpdateBatch
0
 
jayeshshahCommented:
i think the best way is to open a recordset using the XMl file & then execute the insert into statement to insert in the SQL Server.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now