I'm a developer with a little DB knowledge. I need to develop a code that among other things, imports and exports a table to/from file.
I'm using the bcp utility, and it all goes OK.
I need to implement both append and truncate. Meaning, if the user chooses to import data from file he can ask that previous data will be deleted, and the table will contain only the data in the file. This goes OK also, I first truncate the table and then use the BCP utility.
My problem is with the append. The first time, the BCP tries to upload a record that its key already exists, it stops. I want the BCP to skip records that already exist.
I've tried to use -m parameter but it didn't help and I didn't find any other parameter that fits.
I'm using MSSQL 8.00.194. The parameters that I use for exporting the table to file are:
bcp table_name file_name -e -c -C -U -P -S -t -r