如果 Excel 列超过 8224 个字符,则 OPENROWSET 错误
OPENROWSET error if Excel column has more than 8224 characters
我使用 OPENROWSET 导入了 Excel 文件。如果列 <= 8224 个字符,它会起作用。我的代码如下:
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0 Xml;HDR=YES;IMEX=1;Database=E:\Test\TestImport3.xls;',
'Select * From [Sheet1$]')
这个测试文件只有一列8224个字符,而且运行没有任何错误。
但是在我再添加 1 个字符后,它引发了如下错误:
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"
returned message "External table is not in the expected format.". Msg
7303, Level 16, State 1, Line 3 Cannot initialize the data source
object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server
"(null)".
谁能给我一些建议?感谢并抱歉我的英语不好
我找到了这个 link 的根本原因:https://support.microsoft.com/en-us/help/2836058/access-errors-during-import-export-to-excel-xls
有一些方法可以解决这个问题:
改用 *.xlsx 格式
限制任何 memo/long 文本字段的长度小于 8224 字节
导出时,删除现有的 .xls 文件,然后再使用相同的文件名执行导出
在 Excel 中打开 .xls 文件,然后从 Access
执行 import/export
我使用 OPENROWSET 导入了 Excel 文件。如果列 <= 8224 个字符,它会起作用。我的代码如下:
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0 Xml;HDR=YES;IMEX=1;Database=E:\Test\TestImport3.xls;',
'Select * From [Sheet1$]')
这个测试文件只有一列8224个字符,而且运行没有任何错误。 但是在我再添加 1 个字符后,它引发了如下错误:
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "External table is not in the expected format.". Msg 7303, Level 16, State 1, Line 3 Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
谁能给我一些建议?感谢并抱歉我的英语不好
我找到了这个 link 的根本原因:https://support.microsoft.com/en-us/help/2836058/access-errors-during-import-export-to-excel-xls
有一些方法可以解决这个问题:
改用 *.xlsx 格式
限制任何 memo/long 文本字段的长度小于 8224 字节
导出时,删除现有的 .xls 文件,然后再使用相同的文件名执行导出
在 Excel 中打开 .xls 文件,然后从 Access
执行 import/export