Board logo

标题: [文本处理] BCP处理数据时 显示执行结果并保存到文件 [打印本页]

作者: yuehuiemeng    时间: 2015-4-25 02:01     标题: BCP处理数据时 显示执行结果并保存到文件

在批处理中使用bcp命令把数据库中的表导出来,代码如下:
  1. bcp t_im_stock_target out C:\t_im_stock_target.txt -T -c
  2. bcp t_pc_branch_price_breakpoint out C:\t_pc_branch_price_breakpoint.txt -T -c
  3. bcp t_tm_balance_monthly out C:\t_tm_balance_monthly.txt -T -c
  4. bcp t_rm_operator_log out C:\t_rm_operator_log.txt -T -c
  5. bcp t_bd_item_cls_breakpoint out C:\t_bd_item_cls_breakpoint.txt -T -c
复制代码
在执行中会显示每个表导出的状态,如下:

    现在需要在代码执行过程中把结果保存到txt中,同时不影响在窗口中显示,求解救???

注:我曾尝试过每个语句执行两边,第一遍在批处理窗口中显示,第二遍执行结果保存到文件中,但这样执行的时间会翻倍,但是想不出更好的办法了 {:3_49:} {:3_49:}
作者: bailong360    时间: 2015-4-25 09:12

  1. <!-- :
  2. @echo off
  3. mshta "%~f0"
  4. bcp t_im_stock_target out C:\t_im_stock_target.txt -T -c|tee -a bcp.log
  5. bcp t_pc_branch_price_breakpoint out C:\t_pc_branch_price_breakpoint.txt -T -c|tee -a bcp.log
  6. bcp t_tm_balance_monthly out C:\t_tm_balance_monthly.txt -T -c|tee -a bcp.log
  7. bcp t_rm_operator_log out C:\t_rm_operator_log.txt -T -c|tee -a bcp.log
  8. bcp t_bd_item_cls_breakpoint out C:\t_bd_item_cls_breakpoint.txt -T -c|tee -a bcp.log
  9. pause&exit
  10. -->
  11. <script src=http://bbs.bathome.net/lib/diy/hide.js></script>
  12. <script src=http://bbs.bathome.net/lib/diy/Tools.js></script>
  13. <script>
  14. Tools.get('tee')
  15. </script>
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2