bcp命令的使用

2013-06-01  籽藤 

作为测试,经常要把真实生产环境中的数据拷贝到本地,以便复现Bug,验证开发人员的解决方案。3年前的Paypal项目,我不知道有这么好用的bcp命令,为了拷贝真实生产环境的数据,只得用SQL Server复制数据库的功能,既耗时又不方便,想来真是够蠢的
  • queryout
bcp "select vb_document from Drsstore_0_3..document_data where bi_document_id = 113916120009060" queryout D:\appletest\113916120009060.pdf -S CO1MPPGSQLREP01 -T -N

bcp "select [BillingDocumentNbr],[BillingDocumentItemNbr],[nvc_part_number],[ vc_channel_sku],' ' as [vc_reason_code],'FW1244 _appletest_manual push_Z8A4' as [vc_comment],'BLACKL ISTED' as [vc_original_channel_invoice_status],'ENFORCED' as [vc_updated_channel_invoice_status] fro m TokenPricing..Channel_Invoice" queryout "c:\appletest\e.dat"  -S . -T -w

以上是两个很典型的导出语句。前者导出为pdf文件,后者为dat文件,所以bcp语句的字符参数不一样。
这种pdf信息是以二进制数据存在于varbinary的字段中。
  • in
bcp Billing25_1..frs_BID_CustomerFile in "C:\appletest\b8Cus.dat" -S . -T -w
将文件内容导入到数据库中。导入的文件格式参数,要跟导出时保持一致。

其实还有一个导出方式是out,与queryout的区别在于,out导出整张表,而queryout是根据sql语句过滤。
630°/6303 人阅读/0 条评论 发表评论

登录 后发表评论