Importing Excel

  • I've been assigned a simple on-the-side project where I need to load an excel file into an SQL 2k5 DB. I just need to load a list of numbers into a temp table, join them with a view, then capture the results to a CSV file.

    The problem I've been having is loading the excel dataset then dumping that dataset into a table. I was hoping to not have to read the dataset row-by-row and 'insert'. I'm using .Net 1.1, so I can't use the SQLBulkLoad.

    I was hoping something like this

    pseudo code:

    DataAdapter1 = Excel

    DataAdapter2 = SQL

    Dataset = DataAdapter1.Load

    DataAdapter2.Insert(Dataset,"SomeTable")

    If someone could point me in the right direction as most google hits has involved the new .Net 2.0 SQLBulkLoad or weren't doing what I needed.

  • You've got me... I use OPENROWSET for that type of stuff. Or, better yet, I'll have Excel write an importable CSV when they close the spreadsheet.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • use OPENROWSET, for more info: http://www.mssqltips.com/tip.asp?tip=1202

  • if your situation doesn't allow you to use OPENROWSET, a simple integration services package could do the trick as well.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply