Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2003
    Posts
    97

    Unanswered: Is not possible to add only new rows Bulk Insert?

    I have a CSV log file that's being constantly updated by another process and I need to store new rows since the last Bulk Insert from this CSV into a table. I've searched everywhere and can't find anything related to this, but maybe I'm missing something? Can someone please shed some light?

    Thanks very much

  2. #2
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Look into OpenRowSet

  3. #3
    Join Date
    Mar 2003
    Posts
    97
    I configured the server (SQL 2k5) with Ad Hoc Distributed Queries and when I run this statement:
    select * from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};
    DefaultDir=C:\log;','select * from acct-2009-03-17.csv')

    I get this error:
    OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Text Driver] Syntax error in FROM clause.".
    Msg 7321, Level 16, State 2, Line 1
    An error occurred while preparing the query "select * from acct-2009-03-17.csv" for execution against OLE DB provider "MSDASQL" for linked server "(null)".

    From BOL:
    "This method is an alternative to accessing tables in a linked server and is a one-time, ad hoc method of connecting and accessing remote data by using OLE DB."

    Yet, the error message seems as if I need to register the server as a linked server?

    Thoughts?

  4. #4
    Join Date
    Mar 2003
    Posts
    97
    I figured it out... stupid MS SQL doesn't like the dashes in the file name. grrrrrr

  5. #5
    Join Date
    Dec 2010
    Posts
    1
    Only registered and reviving a dead thread just to thank you for posting your own follow-up solution! The error message is ambiguous and I was at a loss. I noticed my filenames were similar to yours, but I probably wouldn't have thought to remove dashes. However, I also discovered that surrounding my filename with quotes will also work.

    Code:
    select * from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};
    DefaultDir=C:\log;','select * from "acct-2009-03-17.csv"')

  6. #6
    Join Date
    Mar 2003
    Posts
    97
    Happy to help! Merry XMas :-)

Posting Permissions

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