My source CSV is comma delimited.
Example
Col1, Col2, Col3
Destinatin SQL Table
Col1, Col2, Col3, Col4, Col5 ( Col4 and Col5 are like audit columns)
So when i do bcp import can these Col4 and Col5 set to some default values or should I have to massage the data / source file to include these before i execute bcp cmd.
Which is preferred way.
Use SSIS to read source / derive audit columns and map to destination.
or any other right way.
I think you have a couple of options:
Change the schema of your destination table to include
DEFAULTconstraints on the two columns that will not get updated with values from your import file (and then remove them later if you don’t need themBuild an SSIS package — it would probably take about the same amount of time as it would take you searching the Interweb for a solution using
bcpTry using
BULK INSERTthroughsqlcmd.exeor SQL Server Management Studio and adding in default values (SELECT c1, c2, c3, 'My default', GETDATE() FROM OPENROWSET('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};)DefaultDir=C:\Path\To\Folder\With\CSV;','SELECT * FROM MyCsv.csv')