SQL Server 2012 querying Access 2007 data using OPENROWSET error

Finally, after several unsuccessful attempts to have SQL Server "talk to" an Access database – either as a "Linked Server" in SSMS or via OPENROWSET() in T-SQL – I found this blog post that offered the following three (3) suggestions.

Tweak #1: OLE DB Provider settings

The OLE DB Provider for ACE (or Jet) must have the "Dynamic parameter" and "Allow inprocess" options enabled. In SSMS, open the

Server Objects > Linked Servers >Providers

branch, right-click "Microsoft.ACE.OLEDB.12.0" (or "Microsoft.Jet.OLEDB.4.0"), choose "Properties", and ensure that those options are selected:

ProviderOptions.png

Tweak #2: Temp folder permissions

This is the one that was stumping me.

Apparently SQL Server needs to write information into a temporary file while running an OLE DB query against an Access database. Because SQL Server is running as a service it uses the %TEMP% folder of the account under which the service is running.

If the SQL Server service is running under the built-in "Network Service" account then the temp folder is

%SystemRoot%\ServiceProfiles\NetworkService\AppData\Local\Temp

and if it is running under the built-in "Local Service" account then the temp folder is

%SystemRoot%\ServiceProfiles\LocalService\AppData\Local\Temp

My problem was that SSMS was running under my account (not NETWORK SERVICE) so I only had Read access to the Temp folder

OldPermissions.png

Once I granted myself Modify permissions on that folder

NewPermissions.png

and enabled OPENROWSET queries as documented in another question here, namely ...

EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

... my query worked fine:

MyQuery.png

Tweak #3: memory_to_reserve

Although I didn't need to use it in my case, the aforementioned blog also claims that adjusting the "-g memory_to_reserve" startup parameter for the SQL Server service can also help avoid similar errors. To do that:

  • launch SQL Server Configuration Manager
  • right-click the SQL Server service ("SQL Server Services" tab) and choose "Properties"
  • on the "Advanced" tab, prepend -g512; to the "Startup Parameters" setting
  • restart the SQL Server service

For more details on the "memory_to_reserve" setting see the MSDN article here.


This should work

EXEC sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE;  
GO  
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;  
GO  
RECONFIGURE;  
GO

USE [DatabaseName]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

SELECT *  FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0','Data Source="C:\Employees.accdb"')...tblEMPS;