Need to read CSV file information one by one. i.e. If the customer in the file is existing in Customer table insert into detail table otherwise insert into error table. So I can’t use bulk insert method.
How to read one by one record from CSV file? How to give the path?
Bulk insert method is not going to work here.
One option is to use an
INSTEAD OF INSERTtrigger to selectively put the row in the correct table, and then use your normalBULK INSERTwith the optionFIRE_TRIGGERS.Something close to;
If you’re importing files regularly, you can create a table (ImportTable) with the same schema, set the trigger on that and do the imports to
MyTablethrough bulk import toImportTable. That way you can keep the trigger and as long as you’re importing toImportTable, you don’t need to do any special setup/procedure for each import.