Esat Erkec shows us how to use the Bulk Copy Program (BCP) to bulk load data into SQL Server:
If the installed version is older than the last version, we can download and install the latest version from the Microsoft website. The main capability of the SQL Server BCP is not much complex because it can only run with several arguments. The syntax of the BCP is like below:
bcp {table|view|”query”} {out|queryout|in|format} {data_file|nul} {[optional_argument]…}
For example, if we want to export any data of a table to a text file, we have to specify the table name, the out option, and the data file. The following command will export the Production table into the specified text file.
bcp AdventureWorks2017.Production.Product out C:\ExportedData\Product.txt -S localhost -T –w
I don’t know if I’m the only person for which this is true, but the data file format has always been a royal pain for me to get right, to the point where I’d happily build an SSIS package to perform bulk loading over having to use BCP myself.
I end up using the BCP API in Powershell
much easier
Fair enough. I don’t remember if I ever tried that, though it’s not ringing a bell. It has been several years since I last tried BCP, so I remember the pain but not all of the details.