SqlBulkCopy

public static void AddByBluckCopy(DataTable table, string tableName)
{
if (table != null && table.Rows.Count > 0)
{
string connectstring = PubConstant.ConnectionString;
using (SqlBulkCopy bulk = new SqlBulkCopy(connectstring))
{
bulk.BatchSize = 1000;
bulk.BulkCopyTimeout = 100;
bulk.DestinationTableName = tableName;
bulk.WriteToServer(table);
}
}
}

你可能感兴趣的:(SqlBulkCopy)