SqlBulkCopy will only allow for uploading files to a destination table comprised of [n]varchar columns only.
The default CSVReader column type is string and if this does not match the table type then SQLBulkCopy throws an error.
CSV column data types need to be set prior to Bulk Copy such that they match the SQL table data types. (See here)
Ideally this should be done dynamically by determining the SQL table types (SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'destTable') and then converting to DataReader types
SqlBulkCopy
will only allow for uploading files to a destination table comprised of[n]varchar
columns only.The default CSVReader column type is
string
and if this does not match the table type then SQLBulkCopy throws an error.CSV column data types need to be set prior to Bulk Copy such that they match the SQL table data types. (See here)
Ideally this should be done dynamically by determining the SQL table types (
SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'destTable'
) and then converting to DataReader types