Strings longer than 255 characters are not copied by SqlBulkCopy.

excel sqlbulkcopy

Question

A large Excel spreadsheet has to be copied into the SQL Server database. I am reading all of the data from the [Sheet1$] by opening an OldDbConnection to the Excel spreadsheet. I then obtain an IDataReader with the spreadsheet data using the OleDbCommand.

The Excel document has a number of cells with text that is longer than 256 characters. However, when I use SqlBulkCopy to transfer this to the database table, I only see the first 255 characters from these excel columns. The fields in the database table may hold 5000 characters.

Does SqlBulkCopy have a field size restriction? Thanks!

1
0
4/20/2009 5:11:52 PM

Popular Answer

SqlBulkCopy and OldDbConnection are unfamiliar to me.
Excel may only be providing the first 255 characters, however.
When accessing a cell's value in Excel, the first 255 characters are returned if you use the.value property, and the whole text is returned if you use the.text property. I hope this helps you with your thinking.

0
4/20/2009 9:12:39 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow