zoukankan      html  css  js  c++  java
  • 利用sqlserver 提供的bcp.exe插入数据

    class bcpHelper
        {
            public static StreamWriter SW_log { get; set; }
            static string bcpExePath = Environment.GetEnvironmentVariable("programfiles")+
                @"Microsoft SQL Server100ToolsBinncp.exe";
    
            public static void BatchInsertProcess(string dbName,string svName,string sourceFile,string targetTable,
                string errorFile,string outBcpFile)
            {
               //-c则要求要插入的文件编码为ascii编码,-w则为Unicode
               string args = "["+dbName+"]" + ".." +"["+ targetTable+"]" + " in "" + sourceFile + """ +
                        " -S " + svName + " -T -w -t "," -e ""+errorFile+"" -o ""+outBcpFile+""";
               shellHelper.executeShellCmd(bcpExePath, args);
             
                //判断bcp是否成功
               FileInfo fi = new FileInfo(errorFile);
               if (fi.Length == 0)
               {
                   Console.WriteLine("Error:Fail to process bcp!");
                   txtWriteHelper.AppendLog(SW_log, "Error:Fail to process bcp!");
               }
            }
        }
  • 相关阅读:
    maven打包
    (和)后台解析
    beetl简单阅览
    snmp在win10上安装使用
    javaMail发送邮件
    mysql 安装配置详解
    vsftpd的主配置文件详解
    linux下vi命令笔记
    linux下sed命令笔记
    linux下grep命令笔记
  • 原文地址:https://www.cnblogs.com/nora/p/8064265.html
Copyright © 2011-2022 走看看