public static void SqlBulkCopy(SqlConnection connection, DataTable table, string destinationTable)
{
connection.Open();
try
{
var sqlBulkCopy = new SqlBulkCopy(connection);
sqlBulkCopy.DestinationTableName = destinationTable;
foreach (DataColumn column in table.Columns)
{
sqlBulkCopy.ColumnMappings.Add(column.ColumnName, column.ColumnName);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
connection.Close();
}
}
INSERT INTO USERS VALUES
(2, 'Michael', 'Blythe')
GO 10