I am trying to import an excel 2007 file in sql server 2005 using linked server. I found instructions how to use excel files as linked server in 2005 but for the provider string I used 'Excel 12.0' instead of 'Excel 8.0' because I am using Excel 2007 file.
In SQL Server Management Studio, expand Server Objects in Object Explorer.
Right-click Linked Servers, and then click New linked server.
In the left pane, select the General page, and then follow these steps:
In the first text box, type any name for the linked server.
Select the Other data source option.
In the Provider list, click Microsoft Jet 4.0 OLE DB Provider.
In the Product name box, type Excel for the name of the OLE DB data source.
In the Data source box, type the full path and file name of the Excel file.
In the Provider string box, type Excel 8.0 for an Excel 2002, Excel 2000, or Excel 97 workbook.
Click OK to create the new linked server.
I keep getting this error:
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "EXCEL_MY_FILE" does not contain the table "Report 1$". The table either does not exist or the current user does not have permissions on that table.
I went into security and added nt authority\system just in case it was permissions problem and it still gave me the error.
The excel table is called 'Report 1'.
My settings in linked server are as below:
Provider: Microsoft Office 12.0 Access Database Engine OLE DB Provider
Product Name: Excel
Data source: C:\Documents and Settings\UserName\Desktop\Main\FilesIns\MyExcelFile.xlsx
Provider String: Excel 12.0
Hope someone can tell me what is wrong?
I tried running this in sql server:
EXEC sp_configure 'show advanced options', 1
EXEC sp_configure 'ad hoc distributed queries', 1
As I was trying to use openrowset to see if that would work but I got error:
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server.
Now I get:
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Syntax error in FROM clause.".
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "Select * from C:\Documents and Settings\UserName\Desktop\Main\FilesIns\MyExcelFile.xlsx" for execution against OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
I'm not sure if my openrowset values are correct
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;DATABASE=C:\Documents and Settings\UserName\Desktop\Main\FilesIns\MyExcelFile.xlsx', 'Select * from C:\Documents and Settings\UserName\Desktop\Main\FilesIns\MyExcelFile.xlsx')