Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Grifter
Constraint Violating Yak Guru
274 Posts |
Posted - 2013-08-30 : 04:13:14
|
HiI 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. From here:http://support.microsoft.com/kb/306397/EN-USquote: 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: quote: 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:quote: Provider: Microsoft Office 12.0 Access Database Engine OLE DB ProviderProduct Name: ExcelData source: C:\Documents and Settings\UserName\Desktop\Main\FilesIns\MyExcelFile.xlsxProvider String: Excel 12.0Location: Catalog:
Hope someone can tell me what is wrong?ThanksGUpdate:I tried running this in sql server:EXEC sp_configure 'show advanced options', 1RECONFIGUREGOEXEC sp_configure 'ad hoc distributed queries', 1RECONFIGUREGO As I was trying to use openrowset to see if that would work but I got error: quote: 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: quote: 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 1An 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 correctSELECT * 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') |
|
Grifter
Constraint Violating Yak Guru
274 Posts |
Posted - 2013-08-30 : 07:51:11
|
Panic over just imported it using database > right click > Tasks > Import and use flat file if you are doing this. Also remove column headings in excel/flat file as your sql table already has these. |
|
|
|
|
|
|
|