I'm trying to read data from an Excel spreadsheet into SQL, but for some reason some of fields are showing as NULL even though the spreadsheet has data in that particular column/row (in this instance it's a number).

All of the other column/rows that have text show up OK.

This is the query I am using

select * from 
OPENROWSET ('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=G:\XLS\ACK.xls', [ACK$])

I'm using SQL server management studio 2005 to run the query.

Any ideas/suggestions as to why this is happening? Thanks.

有帮助吗?

解决方案

looks like if i use CSV instead of XLS then i get all the data intact

select *
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)}; DefaultDir=G:\xls\;Extensions=CSV;',
'select * from ack2.csv')
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top