SqlBulkCopy does not copy strings > 255 characters long

excel sqlbulkcopy

Question

I am trying to copy a large Excel spreadsheet into the SQL Server database. I am opening an OldDbConnection to the Excel spreadsheet and reading everything from the [Sheet1$]. Then, I am using the OleDbCommand to get a IDataReader with the spreadsheet data.

There are several cells in the Excel sheet with text contents of more than 256 characters. But, once this gets uploaded to the database table using SqlBulkCopy, I only see first 255 characters from these excel cells in the database. The database table fields are 5000 characters long.

Does SqlBulkCopy limit the field size? Thanks!

Popular Answer

I am not aware of SqlBulkCopy and OldDbConnection.
however Excel might be giving out first 255 chars.
In Excel if you access a cells value with .value property you get first 255 chars, and if you acccess it with .text property you get full text. Hope this will give you some idea.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why