Microsoft.ACE.OLEDB.12.0 Cannot execute the query

3.4k views Asked by At

I have this sql code. It updates a specific cell in an excel file.

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). I get this error in 64bit:

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.

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. In fact, this code works fine but not with the UPDATE statment:

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!

1

There are 1 answers

2
Temp On BEST ANSWER

The excel file must be created/resaved from a 64bit MS Office. That's all!