• John Bigler - Monday, January 23, 2017 6:49 AM

    Good morning all.  

    Nothing wrong with these solutions, but I prefer something more direct like just treating the CSV files as virtual tables and reading them using OPENROWSET instead of created linked servers.  An example:

    SELECT
         Identifier
         , FirstName
         , Surname
         , PostalCode
      FROM OPENROWSET('MSDASQL'
         ,'Driver={Microsoft Access Text Driver (*.txt, *.csv)};DefaultDir=C:\LoadDir\'
         ,'SELECT * FROM "MyDataFile.csv"')

    How do you define the delimiter to be a semi-colon as in the example data provided? 😉

    --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)