[英]Microsoft.ACE.OLEDB.12.0 Cannot execute the query
I have this sql code. 我有这个sql代码。 It updates a specific cell in an excel file. 它更新excel文件中的特定单元格。
SET @cmd = 'UPDATE OPENROWSET(''Microsoft.ACE.OLEDB.12.0'',''Excel 12.0;Database=C:/sompath/file.xls;HDR=NO;IMEX=0;'',''SELECT F1,F2,F3,F4,F5,F6,F7,F8,F9 FROM [Sheet1$]'')
set [F1] = ''Hello World''
where [F1] = ''<field1>'''
EXEC(@cmd)
This piece of code executes successfully in 32bit but fails in 64bit server (MSSQL Server 2012). 这段代码在32位成功执行,但在64位服务器(MSSQL Server 2012)中失败。 I get this error in 64bit: 我在64位中收到此错误:
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "No value given for one or more required parameters.".
Msg 7320, Level 16, State 2, Line 1
Cannot execute the query "SELECT F1,F2,F3,F4,F5,F6,F7,F8,F9 FROM [Sheet1$]" against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
The file.xls
is an excel file created in a 32bit pc. file.xls
是一个用32位pc创建的excel文件。
Can someone help me with this issue. 有人可以帮我解决这个问题。 I've been searching around the net but really did not get the solution or even some guide to resolving it. 我一直在网上搜索,但实际上没有得到解决方案,甚至没有解决它的指南。 If this question has already been posted and answered, just kindly post the exact link please. 如果这个问题已经发布并得到解答,请发布确切的链接。
By the way, I have already installed the ACE provider and all those settings needed. 顺便说一下,我已经安装了ACE提供程序以及所需的所有设置。 In fact, this code works fine but not with the UPDATE statment: 实际上,此代码工作正常,但不是UPDATE语句:
DECLARE @cmd VARCHAR(1000)
set @cmd = 'SELECT * FROM
OPENROWSET(''Microsoft.Ace.OLEDB.12.0'',
''Excel 12.0;Database=C:/sompath/file.xls;HDR=NO;IMEX=0'',[Sheet1$])'
EXEC(@cmd)
Thanks! 谢谢!
The excel file must be created/resaved from a 64bit MS Office. 必须从64位MS Office创建/重新保存excel文件。 That's all! 就这样!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.