Troubleshooting Guide: SQL Server Error 5356 — “Specifying Database or Server Credential Is Not Supported for OPENROWSET”
Why This Error Happens
This error occurs because SQL Server 2025’s OPENROWSET function, when used in bulk data access mode (e.g., reading files via BULK or ad hoc queries), does not support inline specification of database-scoped or server-scoped credentials directly in the function call. Instead, SQL Server expects authentication to be handled through a properly configured Database Scoped Credential tied to an External Data Source, rather than passed as a parameter. This typically surfaces when legacy T-SQL scripts or migrated queries attempt to pass credentials in a syntax pattern no longer supported by the current Database Engine.
Step-by-Step Resolution Guide
Step 1: Verify Ad Hoc Distributed Queries Configuration
- Open SQL Server Management Studio (SSMS) and connect to your SQL Server 2025 instance.
- Run the following to confirm the feature is enabled:
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'Ad Hoc Distributed Queries';
- If the
run_valueis0, enable it:
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
Step 2: Create a Proper External Data Source and Credential
- Instead of embedding credentials in the
OPENROWSETcall, create a dedicated Database Scoped Credential:
CREATE DATABASE SCOPED CREDENTIAL MyAzureCredential
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = '<your_sas_token>';
- Link this credential to an External Data Source:
CREATE EXTERNAL DATA SOURCE MyExternalSource
WITH (
TYPE = BLOB_STORAGE,
LOCATION = 'https://yourstorageaccount.blob.core.windows.net/container',
CREDENTIAL = MyAzureCredential
);
Step 3: Rewrite the OPENROWSET Query
- Remove any inline
CREDENTIAL=parameters from theOPENROWSETsyntax. - Reference the External Data Source instead:
SELECT *
FROM OPENROWSET(
BULK 'folder/file.csv',
DATA_SOURCE = 'MyExternalSource',
FORMAT = 'CSV'
) AS DataFile;
Step 4: Restart SQL Server Services
- On Windows Server 2025 / Windows 11, open Services.msc.
- Restart SQL Server (MSSQLSERVER) and SQL Server Agent to apply configuration changes.
- Confirm the instance reloads advanced configuration flags without reverting to default.
Alternative or Verification Steps
- Run a test query using the updated
OPENROWSETsyntax withDATA_SOURCEinstead of direct credentials; confirm Error 5356 no longer appears in SSMS or the Windows Event Viewer (under Applications and Services Logs > MSSQLSERVER). - If the error persists, verify that the SQL Server service account has proper NTFS/network permissions to the external storage location, as misconfigured permissions can mimic the same error when credentials silently fail to resolve.