Thursday 19 May 2022

Create shell script reading csv file and inserting SQL Server

Create a shell script

https://www.mssqltips.com/sqlservertip/5623/linux-commands-to-assist-with-importing-a-csv-file-into-sql-server/

Above link's bcp command options didn't work.





Correct bcp command options could be found in:

https://docs.microsoft.com/en-us/azure/azure-sql/load-from-csv-with-bcp?view=azuresql

https://datacadamia.com/db/sql_server/bcp#csv


Also, make sure you didn't open the csv file.

https://stackoverflow.com/questions/39465354/bcp-error-unable-to-open-bcp-host-data-file

After changing 'Year' as int type, import had error.




To delete 1st line of csv file you have tail -n +2 or sed option.

https://stackoverflow.com/questions/604864/print-a-file-skipping-the-first-x-lines-in-bash


Import all working well. bcp -e option could be used for log. But it seems making an empty log although there is no error.










Run script from Informatica


No comments:

Post a Comment