Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server: BCP vs SQLCMD - what is more efficient?

I'm writing a program in c# to export SQL Server data from one database and importing it in another. Since these two servers are not connected I need to choose a method such as bcp.

  1. What are the differences between these two? Is one more efficient than the other? And in what scenarios?
  2. What are the known limitations/compatibility issues of each?
  3. What other methods exist to export data from SQL Server into files and import from them?
  4. Can I enable compression in these files at the same time as creating them via a command line switch instead of zipping them afterwards?
  5. Please include any other aspects which you think is important when making this decision.

Thanks in advance.

like image 722
Harindaka Avatar asked Jul 24 '26 08:07

Harindaka


1 Answers

Doesn't cover BCP, but I did write a blog post comparing a couple of approaches for bulk loading data into SQL Server - compared SqlBulkCopy against batched inserts via SqlDataAdapter.

SqlBulkCopy is worth checking out - the kind of process you'd use is query database 1 and retrieve an SqlDataReader. Pass that SqlDataReader to SqlBulkCopy to persist that data to database 2.

like image 155
AdaTheDev Avatar answered Jul 26 '26 09:07

AdaTheDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!