Insert data from XML file to SQL Database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dray

    Insert data from XML file to SQL Database

    Hi,

    Could anyone please give me a code example of how to insert data from
    an XML file into a SQL database. So far I've got the data sitting in a
    dataset...

    Thanks
  • sloan

    #2
    Re: Insert data from XML file to SQL Database


    Sql Server 2000 , OPENXML. Send the xml in as text (one way).
    ds.GetXml() will work.

    Sql Server 2005? SP2 introduced an slowness bug.


    You'll have to consider sending in your ds.GetXml ..but convert it to
    attribute based first.


    Helper articles:
    http://sholliday.space s.live.com/blog/cns!A68482B9628 A842A!148.entry
    T-SQL has some well known limitations when working with parameters for a stored procedure, not the least of which is a variable number of parameters. While there are some solutions, they can be cumbersome to work with. Sloan Holliday brings us a creative solution using XML that can solve many issues.



    Good luck.




    "Dray" <alex@boxtop.co .ukwrote in message
    news:7fe79421-07f3-4266-bc4a-7082adf2b8c2@x3 5g2000hsb.googl egroups.com...
    Hi,
    >
    Could anyone please give me a code example of how to insert data from
    an XML file into a SQL database. So far I've got the data sitting in a
    dataset...
    >
    Thanks

    Comment

    • Dray

      #3
      Re: Insert data from XML file to SQL Database

      On 8 Aug, 16:45, "sloan" <sl...@ipass.ne twrote:
      Sql Server 2000 , OPENXML.  Send the xml in as text (one way).
      ds.GetXml() will work.
      >
      Sql Server 2005?  SP2 introduced an slowness bug.http://connect.microsoft.com/SQLServ...dback.aspx?Fee...
      >
      You'll have to consider sending in your ds.GetXml ..but convert it to
      attribute based first.
      >
      Helper articles:http://sholliday.space s.live.com/blog/cns!A68482B9628 A842A!148.entry http://www.sqlserverce ntral.com/articles/Stored+Procedur es/thezeroton...http://www.ipass.net/sloan/code/OPEN...yntax_Test.txt
      >
      Good luck.
      >
      "Dray" <a...@boxtop.co .ukwrote in message
      >
      news:7fe79421-07f3-4266-bc4a-7082adf2b8c2@x3 5g2000hsb.googl egroups.com...
      >
      >
      >
      Hi,
      >
      Could anyone please give me a code example of how to insert data from
      an XML file into a SQL database. So far I've got the data sitting in a
      dataset...
      >
      Thanks- Hide quoted text -
      >
      - Show quoted text -
      Hi, thanks for your help. I was however thinking of using sqldataapter
      update to do this but are not sure how to go about it...

      Comment

      • sloan

        #4
        Re: Insert data from XML file to SQL Database


        I think you're barking up the wrong tree, but that's me.

        SqlDataAdapters have a very "row by row"-ness to them.

        If you want the "set based" or "bulk-ness" of xml, I think you'll have to do
        some coding.

        Here is one last helper article:


        ........




        "Dray" <alex@boxtop.co .ukwrote in message
        news:657d5ef7-d9d5-4fec-87e6-49debd7274e6@j2 2g2000hsf.googl egroups.com...
        On 8 Aug, 16:45, "sloan" <sl...@ipass.ne twrote:
        Sql Server 2000 , OPENXML. Send the xml in as text (one way).
        ds.GetXml() will work.
        >
        Sql Server 2005? SP2 introduced an slowness
        bug.http://connect.microsoft.com/SQLServ...dback.aspx?Fee...
        >
        You'll have to consider sending in your ds.GetXml ..but convert it to
        attribute based first.
        >
        Helper
        articles:http://sholliday.space s.live.com/blog/cns!A68482B9628 A842A!148.entry http://www.sqlserverce ntral.com/articles/Stored+Procedur es/thezeroton...http://www.ipass.net/sloan/code/OPEN...yntax_Test.txt
        >
        Good luck.
        >
        "Dray" <a...@boxtop.co .ukwrote in message
        >
        news:7fe79421-07f3-4266-bc4a-7082adf2b8c2@x3 5g2000hsb.googl egroups.com...
        >
        >
        >
        Hi,
        >
        Could anyone please give me a code example of how to insert data from
        an XML file into a SQL database. So far I've got the data sitting in a
        dataset...
        >
        Thanks- Hide quoted text -
        >
        - Show quoted text -
        Hi, thanks for your help. I was however thinking of using sqldataapter
        update to do this but are not sure how to go about it...


        Comment

        Working...