public static bool RunBat(IDBHelper db, string sql, bool throwException, DbTransaction trans) { db.CommandTimeout = 60 * 30; string[] arr = sql.Split( new string[] { " go ", Environment.NewLine + "go ", " go" + Environment.NewLine, Environment.NewLine + "go" + Environment.NewLine, " GO ", Environment.NewLine + "GO ", " GO" + Environment.NewLine, Environment.NewLine + "GO" + Environment.NewLine, " Go ", Environment.NewLine + "Go ", " Go" + Environment.NewLine, Environment.NewLine + "Go" + Environment.NewLine, " gO ", Environment.NewLine + "gO ", " gO" + Environment.NewLine, Environment.NewLine + "gO" + Environment.NewLine} , StringSplitOptions.RemoveEmptyEntries); foreach (string s in arr) { if (string.IsNullOrEmpty(s) || s.Trim().Length == 0) continue; if (throwException) db.ExecuteNonQuery(db.GetSqlCommand(s), trans); else { try { db.ExecuteNonQuery(db.GetSqlCommand(s), trans); } catch (Exception e) { ErrorLog.Add(e.Message + "=========>" + s); } } } return true; }