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.
- What are the differences between these two? Is one more efficient than the other? And in what scenarios?
- What are the known limitations/compatibility issues of each?
- What other methods exist to export data from SQL Server into开发者_如何转开发 files and import from them?
- Can I enable compression in these files at the same time as creating them via a command line switch instead of zipping them afterwards?
- Please include any other aspects which you think is important when making this decision.
Thanks in advance.
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.
精彩评论