• 利用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!");
               }
            }
        }
  • 相关阅读:
    R-CNN算法中NMS的具体做法
    Spring之Environment
    Spring之Aware
    每晚夜里自我独行,随处荡,多冰冷,以往为了自我挣扎
    Java 反射机制
    Java string String
    Java int Integer
    Java final
    Java toString()方法
    Java Enum
  • 原文地址:https://www.cnblogs.com/nora/p/8064265.html
Copyright © 2020-2023  润新知