how to retrive data from .csv

  • Dear Friends,

    I have to retrive the data from table account & blockId where the account no. is in the " .csv " ( in this .csv file i have only one column with row terminator) file how to retrive the data from it, here is my query

    select a.col1,a.col2,b.col3 from account a,

    inner join blockId b

    on a.acc_id=b.acc_id

    where b.acc_No = 'file.csv'

    Regards,

    Kumar

  • Use bulk insert to import the file into a table and join to it as you normally would.

    As an alternative, you could Create a Linked Sever or OPENROWSET and read from the file directly.

    All 3 methods are clearly described in Books Online (comes free with SQL Server).

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

Viewing 2 posts - 1 through 2 (of 2 total)

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