Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to import xml to SQL?

How to import xml to SQL?

Scheduled Pinned Locked Moved Database
databasehelpcsharplinqxml
8 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thienvan
    wrote on last edited by
    #1

    I have a large xml file and I want to importing data from it to my database using LINQ. - My database has many type of data and my xml file has null value. - xml file has multi table. In T-SQL, I used Dataset.Readxml and using SqlBulkCopy to insert dataset into SQL. My problem is xml file has null value. I want to use LINQ to write it. What should I do? Please help me.

    J P 2 Replies Last reply
    0
    • T thienvan

      I have a large xml file and I want to importing data from it to my database using LINQ. - My database has many type of data and my xml file has null value. - xml file has multi table. In T-SQL, I used Dataset.Readxml and using SqlBulkCopy to insert dataset into SQL. My problem is xml file has null value. I want to use LINQ to write it. What should I do? Please help me.

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      xml doesn't have 'null', so exactly what do you mean? I suspect you mean that you have an element with no value or perhaps 'nil'? If so there are two possibilities. 1. The corresponding database column allows nulls. 2. The corresponding database column does not allow nulls - thus you MUST provide a value. You would do that while processing the file. No one can tell you what a valid value for that is since it depends on business rules.

      T 1 Reply Last reply
      0
      • J jschell

        xml doesn't have 'null', so exactly what do you mean? I suspect you mean that you have an element with no value or perhaps 'nil'? If so there are two possibilities. 1. The corresponding database column allows nulls. 2. The corresponding database column does not allow nulls - thus you MUST provide a value. You would do that while processing the file. No one can tell you what a valid value for that is since it depends on business rules.

        T Offline
        T Offline
        thienvan
        wrote on last edited by
        #3

        Yes, I mean I have an element with no value or perhap null. I want to use LINQ.I have a column date type of data is datetime. And in my xml file, date has no data. I wrote a store procedure use openxml. When I execute it, it return 01/01/1900. I want it return null.

        J 1 Reply Last reply
        0
        • T thienvan

          I have a large xml file and I want to importing data from it to my database using LINQ. - My database has many type of data and my xml file has null value. - xml file has multi table. In T-SQL, I used Dataset.Readxml and using SqlBulkCopy to insert dataset into SQL. My problem is xml file has null value. I want to use LINQ to write it. What should I do? Please help me.

          P Offline
          P Offline
          Prasanta_Prince
          wrote on last edited by
          #4

          http://support.microsoft.com/kb/316005[^] http://weblogs.sqlteam.com/mladenp/archive/2007/06/18/60235.aspx[^] Hope this can help you.

          T 1 Reply Last reply
          0
          • T thienvan

            Yes, I mean I have an element with no value or perhap null. I want to use LINQ.I have a column date type of data is datetime. And in my xml file, date has no data. I wrote a store procedure use openxml. When I execute it, it return 01/01/1900. I want it return null.

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #5

            So just add something to the end of the stored proc to update the invalid value to null.

            T 1 Reply Last reply
            0
            • P Prasanta_Prince

              http://support.microsoft.com/kb/316005[^] http://weblogs.sqlteam.com/mladenp/archive/2007/06/18/60235.aspx[^] Hope this can help you.

              T Offline
              T Offline
              thienvan
              wrote on last edited by
              #6

              Thanks you very much.

              P 1 Reply Last reply
              0
              • J jschell

                So just add something to the end of the stored proc to update the invalid value to null.

                T Offline
                T Offline
                thienvan
                wrote on last edited by
                #7

                Thanks.

                1 Reply Last reply
                0
                • T thienvan

                  Thanks you very much.

                  P Offline
                  P Offline
                  Prasanta_Prince
                  wrote on last edited by
                  #8

                  you are wellcome

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups