USING BULK INSERT to add data to existing tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tezza98
    New Member
    • Mar 2007
    • 38

    USING BULK INSERT to add data to existing tables

    HI i am using BULK INSERT to copy data from a text file into a table that already exists

    Code:
    BULK INSERT dbo.TRANStemp
        FROM 'D:\MSSQL\Data\TRANS.csv' 
    
    	WHERE dbo.TRANStemp.DateTime <> 
        WITH 
        ( 
            FIRSTROW = 2, 
            FIELDTERMINATOR = '\t', 
            ROWTERMINATOR = '\n' 
        )
    WHERE dbo.TRANSTemp.DateTime <> D:\MSSQL\Data\TRANS.csv.col003
    the error message
    Msg 156, Level 15, State 1, Line 4
    Incorrect syntax near the keyword 'WHERE'.
    I know that i can insert all data into a tempory table and then compare the 2 tables and do an insert, but that will increase the overhead to much.

    What i really want is a way to compare the table data to the text file data, and only insert the text file data into the database. Currently the textfiles are just dumped into the tables using dts, after the tables have been emptied, so i need a way to keep the data in the tables, and add new data from the text files whilst making the overhead smaller then it is already.

    any help would be greatly appreciated
Working...