I was inserting bulk data from C# code using sqlbulkcopy.There were 15000 records in temp_upload table.Now somehow the datatable in WriteToServer() method had just one column and 37 rows.
After running it I found that the table just had 37 records.Initially it had 152 columns but after this only 32 columns were left.
What could be the reason for this?
C# code for this
public static void BulkInsert(SqlConnection connection,DataTable DtRecord,string TableName)
{
if (DtRecord == null) throw new ArgumentNullException("dataTable");
// Create & open a SqlConnection, and dispose of it after we are done
connection.Open();
SqlBulkCopy bulkCopy = new SqlBulkCopy(connection);
bulkCopy.DestinationTableName = TableName;
for (int recordLoop = 0; recordLoop < DtRecord.Columns.Count; recordLoop++)
{
bulkCopy.ColumnMappings.Add(DtRecord.Columns[recordLoop].ColumnName, DtRecord.Columns[recordLoop].ColumnName);
}
bulkCopy.WriteToServer(DtRecord);
bulkCopy.Close();
connection.Close();
}