Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

SQL BULK INSERT

 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();
            }
        }
 
PREVIOUS NEXT
Tagged: #SQL #BULK #INSERT
ADD COMMENT
Topic
Name
8+9 =