The knowledgebase at support.microsoft.com indicates this error can be the result of missing files or wrong filepaths in the Windows registry, etc. Check out suggested fixes here: http://support.microsoft.com/kb/283881/en-gb
However, I have also experienced that you will also get this error if your @provstr= for the Linked_Server_Name is set to “Excel 97 workbook” instead of “Excel 8.0”
EXEC master.dbo.sp_addlinkedserver @server = N’Your_Linked_Server_Name’, @srvproduct=N’Excel’, @provider=N’Microsoft.Jet.OLEDB.4.0′, @datasrc=N’C:\MortgagesDatabase\MortgageProduct.xls’, @provstr=N’Excel 97 workbook’
EXEC master.dbo.sp_addlinkedserver @server = N’Your_Linked_Server_Name’, @srvproduct=N’Excel’, @provider=N’Microsoft.Jet.OLEDB.4.0′, @datasrc=N’C:\MortgagesDatabase\MortgageProduct.xls’, @provstr=N’Excel 8.0′
Depending on your OS you could run odbcad32.exe on your SQL Server to bring up the Data Sources screen where you should be able to confirm what ODBC providers the server has installed (or not installed), as the case may be.
If you’re using 64bit, then this error most likely results from the fact 64-bit SQL Server cannot use Jet, as there is no 64-bit OLEDB provider for Jet.
I came across a possible word-around, which could be to execute the following script in MSSMS, and then restart the MSSQLSERVER service:
sp_configure ‘show advanced options’, 1;
sp_configure ‘Ad Hoc Distributed Queries’, 1
You may get the following errors when you run a query on a Linked Server that is configured to use OLEDB 4.0 provider for Microsoft Jet:
Error 7399: OLE DB provider ‘Microsoft.Jet.OLEDB.4.0’ reported an error.
[OLE/DB provider returned message: Unspecified error]
OLE DB error trace [OLE/DB Provider ‘Microsoft.Jet.OLEDB.4.0’ IDBInitialize::Initialize returned 0x80004005: ].
“Error 7399: OLE DB provider ‘MSDASQL’ reported an error. Driver’s SQLSetConnectAttr failed The Microsoft jet database engine cannot open the file ‘(unknown)’. It is already opened exclusively by another user, or you need permission to view its data.”
These problems probably occur because the login account does not have access to the temporary folder of the SQL Server startup account, because the linked server query runs in the context of the login account. If you run a linked server query, SQL Server tries to create a temporary file data source name (DSN) in the temporary folder of the SQL Server startup account.
To work around this problem, you could try the following:
1. Log on to the computer by using the SQL Server start up account.
2. Create a folder named Temp in the operating system installation directory.
3. Permit full access to a non-administrator account on the Temp folder.
4. Set the value of the TEMP and TMP user variables of the SQL Server startup account to the newly created Temp folder. To do so, follow these steps:
a. Right-click My Computer, and then click Properties.
b. Click the Advanced tab, and then click Environmental Variables.
c. In the User variables for Logon User list, click TEMP, and then click Edit.
d. In theVariable Value box, type C:\Temp as the location of the new Temp folder, and then click OK.
e. Repeat steps c and d to set the value of the TMP variable.
f. Click OK two times.
5. Log off, and then log on to the computer by using SQL Server startup account.
6. Restart the SQL Server services.
However, I’ve also experienced that you may get these errors if the datasource (i.e. the file path supplied in the @datasrc parameter of the sp_addlinkedserver query command) does not exist, or is missing. For example, if you forget to copy the file into the folder where the data source parameter of your linked server points to.