JOIN to a CSV file with OPENROWSET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    JOIN to a CSV file with OPENROWSET

    SQL server database can JOIN directly to a XLS spreadsheet using something like
    Code:
    LEFT JOIN OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;
    Database=\\servername\path\to\folder\foldername\Customers.xls',
    'SELECT * FROM [Sheet1$]') xlsheet
    ON account_ref = customer.ref
    Then read data using xlsheet.columnn ame.
    I have a straightforward question.
    How do I do similar but JOIN to a CSV file instead?
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Two options:
    1. BULK INSERT the CSV into a table and join that.
    2. Find OPENROWSET's driver/connectivity string for TEXT files and use that.

    Good Luck!!!

    ~~ CK

    Comment

    Working...