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. BULK data import

BULK data import

Scheduled Pinned Locked Moved Database
csharpdatabasequestion
3 Posts 2 Posters 0 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.
  • P Offline
    P Offline
    pmpdesign
    wrote on last edited by
    #1

    Hello I have a task coming up shortly which involves loading several BILLION rows of data from a text file into SQL 2000. Wondering what the fastest way to do this is eg SQL BULK INSERT or code it up in C# executable etc. Does anyone know any tips or tricks?

    P 1 Reply Last reply
    0
    • P pmpdesign

      Hello I have a task coming up shortly which involves loading several BILLION rows of data from a text file into SQL 2000. Wondering what the fastest way to do this is eg SQL BULK INSERT or code it up in C# executable etc. Does anyone know any tips or tricks?

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      From one text file? Is it at least CSV or fixed-width? The SQL Server bulk copy utility is bcp, but I wouldn't use it for such an extensive import, I'd use a program (written in C#, but that's just me). I would have the program commit and checkpoint its position in the file once in a while (10000 rows?) so it can restart near where it left off after a failure. With bcp you'd probably have to start all over. In my database library routines I also have the ability to make a log entry every so many inserts or seconds so I can watch the log and be sure it's actually still progressing, and get a feel for how long it's taking. With bcp you're flying blind. I do occasionally use bcp for small imports, and it usually involves importing to a sort of "raw" table from whence I can then copy the data to the proper places, especially if data from each row has to be put into several tables.

      P 1 Reply Last reply
      0
      • P PIEBALDconsult

        From one text file? Is it at least CSV or fixed-width? The SQL Server bulk copy utility is bcp, but I wouldn't use it for such an extensive import, I'd use a program (written in C#, but that's just me). I would have the program commit and checkpoint its position in the file once in a while (10000 rows?) so it can restart near where it left off after a failure. With bcp you'd probably have to start all over. In my database library routines I also have the ability to make a log entry every so many inserts or seconds so I can watch the log and be sure it's actually still progressing, and get a feel for how long it's taking. With bcp you're flying blind. I do occasionally use bcp for small imports, and it usually involves importing to a sort of "raw" table from whence I can then copy the data to the proper places, especially if data from each row has to be put into several tables.

        P Offline
        P Offline
        pmpdesign
        wrote on last edited by
        #3

        Thanks for the info. Data is in several files. I'll write some C# stuff to analyse it and make sure there are no errors before load. Tried a test on that yesterday with hundred million rows and only took a couple of minutes. Slow point is SQL import. Commit at intervals is a good idea. Testing 1 million rows import at the moment (C# and Stored Procedure) and getting about 7 minutes. Thats only five days processing for a billion records... Might try SqlBulkCopy class next and see whether thats any faster. Thanks -- modified at 1:40 Friday 4th May, 2007 SqlBulkCopy - 14 seconds!

        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