+ Reply to Thread
Results 1 to 2 of 2

Upload entire sheet to SQL database

  1. #1
    Registered User
    Join Date
    10-01-2007
    Posts
    23

    Upload entire sheet to SQL database

    I know there has to be an easier way to do this. I'm at work right now and I use an existing VBA macro to upload about 40 different sheets of data to a database. For some reason, whoever coded this, decided it would be a great idea to submit each record one line at a time via an INSERT query. Essentially its as follows:

    SQL = "INSERT row1 INTO..."
    run query
    SQL = "INSERT row2 INTO..."
    run query
    Repeat for every row

    This wouldn't be too bad if there were only a few lines, but we're talking 10,000 lines per sheet. This whole process takes hours when it should not take nearly as long.

    I'm assuming there is a way to write some code to insert a block of text (ex: columns A:D) into a table, essentially automating what would be done if I used a DTS package to load a csv or txt file. Am I correct in assuming this? Does anyone know how to do this?

    Thanks!
    Last edited by paulmezick; 01-06-2009 at 02:42 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    At the bottom of this thread is some code that will allow you to open access from excel and import a spreadsheet. Seems like it should point you in the right direction.

    HTH

    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1