SQL Server Error 597: Fix In-Proc Data Access Execution
In this article
SQL Server Error 597 occurs when an application tries to use in-process data access components like OLE DB providers or linked servers that are not properly configured to run inside the SQL Server process. This error blocks queries that rely on external data sources, such as Excel files, Access databases, or remote SQL instances, through OPENROWSET or OPENDATASOURCE. The fix requires enabling ad hoc distributed queries and ensuring the correct provider permissions are set. No third-party tools or server reinstallation are needed—only configuration changes within SQL Server Management Studio.
What You'll Need
- SQL Server Management Studio (SSMS) with administrative privileges
- Access to the target SQL Server instance (local or remote)
- Administrator-level permissions on the SQL Server (sysadmin role recommended)
- Confirmation that the external data source (e.g., Excel, Access, another SQL Server) is accessible from the SQL Server machine
Step-by-Step
- Open SQL Server Management Studio and connect to the instance where the error occurs.
- In the Object Explorer, right-click the server name and select Properties.
- In the Server Properties window, click the Advanced node on the left side.
- Find the setting labeled Ad Hoc Distributed Queries and set its value to True. Click OK to save.
- Open a new Query window and execute the following T-SQL command to enable the OLE DB provider for the specific data source (e.g., Microsoft.ACE.OLEDB.12.0 for Excel or Access):
EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
If you're using an older Jet provider, replaceMicrosoft.ACE.OLEDB.12.0withMicrosoft.Jet.OLEDB.4.0. - Still in the same query window, run this command to allow dynamic parameters:
EXEC sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1 - If you are connecting to another SQL Server as a linked server, ensure the provider is enabled for remote access:
EXEC sp_MSset_oledb_prop N'SQLNCLI', N'AllowInProcess', 1
ReplaceSQLNCLIwithSQLNCLI11if you're using SQL Server 2012 or later. - Restart the SQL Server service. Go to Windows Services (services.msc), find SQL Server (MSSQLSERVER) or the named instance (e.g., SQL Server (SQLEXPRESS)), right-click and select Restart. Wait for the service to fully start before proceeding.
- Test the connection by running a simple query, such as:
SELECT * FROM OPENROWSET(''Microsoft.ACE.OLEDB.12.0'', ''Excel 12.0;Database=C:\Temp\Data.xlsx'', ''SELECT * FROM [Sheet1$]'')
Adjust the file path and sheet name to match your source. If the file is on a network share, use a UNC path like\\ServerName\Share\Data.xlsx. - If the query runs without error, the fix is successful. If you still see Error 597, proceed to Troubleshooting.
Common Mistakes
- Forgetting to restart the SQL Server service after changing provider settings—many changes only take effect after a restart.
- Using the wrong OLE DB provider name (e.g.,
Microsoft.Jet.OLEDB.4.0on 64-bit SQL Server, which doesn’t support Jet). - Running the configuration commands in the wrong database context—always run them in
masteror the default database for the connection. - Assuming file permissions are handled by SQL Server alone—ensure the SQL Server service account has read/write access to the external file or folder.
- Trying to use OPENROWSET with a local file path that uses drive letters (e.g., C:\) when the SQL Server runs under a different user context—use UNC paths for network files.
Tips
- Use
sp_MSset_oledb_proponly if you are certain the provider is installed on the SQL Server machine. Check installed providers via Regedit under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLEDB. - For Excel files, always save as .xlsx (not .xls) and use
Excel 12.0as the connection string parameter. - Consider using SQL Server Integration Services (SSIS) for regular data imports instead of OPENROWSET—it’s more reliable and secure.
- Enable the xp_cmdshell option only if absolutely necessary and disable it immediately after use—it’s a major security risk.
- Test connectivity to the external data source from the SQL Server machine using a simple tool like Excel or Access before attempting the query.
- When using linked servers, configure the security context explicitly using
sp_addlinkedsrvloginto avoid authentication failures.
Troubleshooting
If Error 597 persists after following the steps above:
- Verify the OLE DB provider is actually installed. Open Command Prompt and run
regedit, navigate toHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLEDB. Look for your provider (e.g.,Microsoft.ACE.OLEDB.12.0). If absent, install the Microsoft Access Database Engine Redistributable from Microsoft’s official site. - Check the SQL Server service account. Open Services (services.msc), find the SQL Server service, check the Log On tab. If it runs as Local System, it may lack network access. Switch to a domain account with permissions to the file share, then restart the service.
- If using 64-bit SQL Server, install the 64-bit version of the Access Database Engine. The 32-bit version will not work.
- Ensure the target file is not open in another program (e.g., Excel). Locked files cannot be accessed by SQL Server.
- Test with a minimal dataset: create a new Excel file with one column and one row of data. Try reading it. If that works, the issue is with the original file’s structure or size.
- Check SQL Server error logs via Management Studio > Management > SQL Server Logs. Look for additional details around the time of the error—sometimes it reveals access denied or provider initialization failures.
- If all else fails, disable the in-process execution entirely by setting
AllowInProcessto 0 and use a linked server with the provider configured for remote execution instead.
Frequently Asked Questions
Can I fix Error 597 without restarting SQL Server?
No. Changes to provider settings and ad hoc distributed queries require a service restart to take effect. There is no dynamic reload option.
Do I need to install Microsoft Office on the SQL Server?
No. You only need the Microsoft Access Database Engine Redistributable, which is free and does not require a full Office installation.
Why does this error occur only with Excel files and not with other databases?
Excel files require a specific OLE DB provider (ACE or Jet) that is not enabled by default for in-process use. SQL Server’s native providers for other SQL instances are often pre-configured, but file-based sources are restricted for security.
Is it safe to enable Ad Hoc Distributed Queries?
It carries a security risk because it allows arbitrary data access from external sources. Only enable it temporarily for necessary tasks and disable it afterward if possible. Use linked servers with explicit logins for recurring access instead.
Can I use this fix for PDF or CSV files?
No. OPENROWSET with OLE DB does not support PDF or CSV directly. Use BULK INSERT for CSV files, or convert PDF to structured data via external tools before importing.
What if I get an error saying the provider is not registered?
This means the required OLE DB driver is missing. Download and install the Microsoft Access Database Engine Redistributable from Microsoft’s official download center, choosing the correct architecture (x64 or x86) to match your SQL Server installation.