简体   繁体   English

使用Excel的SQL OPENROWSET

[英]SQL OPENROWSET with Excel

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). 我试图将数据从Excel电子表格读取到SQL中,但是由于某些原因,即使电子表格在该特定列/行中有数据,某些字段也显示为NULL(在这种情况下为数字)。

All of the other column/rows that have text show up OK. 其他所有具有文本的列/行都显示为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. 我正在使用SQL Server Management Studio 2005来运行查询。

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 看起来如果我使用CSV而不是XLS,那么我得到的所有数据都完整无缺

select *
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)}; DefaultDir=G:\xls\;Extensions=CSV;',
'select * from ack2.csv')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM