Troubleshooting Guide: Error 5359 – ERRORFILEDATASOURCE Without ERRORFILE_LOCATION
Why This Error Happens
This error occurs when a BULK INSERT or OPENROWSET(BULK...) statement specifies the ERRORFILE_DATA_SOURCE option without also specifying the required ERRORFILE_LOCATION option. SQL Server 2025 requires both parameters to be defined together because ERRORFILE_DATA_SOURCE only identifies where the external data source lives (such as Azure Blob Storage or an S3-compatible endpoint), while ERRORFILE_LOCATION defines the actual file path for logging rejected rows. Without a valid location path, SQL Server has no destination to write the error log file, causing the statement to fail validation before execution even begins.
Step-by-Step Resolution Guide
Step 1: Review the Bulk Operation Syntax
- Open the T-SQL script or stored procedure that triggered Error 5359.
- Locate the
BULK INSERTorOPENROWSETcommand containing theERRORFILE_DATA_SOURCEclause. - Confirm whether
ERRORFILE_LOCATIONis missing entirely or commented out.
Step 2: Add the ERRORFILE_LOCATION Parameter
- Insert a valid
ERRORFILE_LOCATIONvalue immediately alongsideERRORFILE_DATA_SOURCEin the WITH clause. - Example corrected syntax:
BULK INSERT dbo.TargetTable
FROM 'data/import.csv'
WITH (
DATA_SOURCE = 'MyExternalDataSource',
ERRORFILE = 'errors/import_errors.log',
ERRORFILE_DATA_SOURCE = 'MyExternalDataSource',
ERRORFILE_LOCATION = 'errors/import_errors.log'
);
- Ensure the path format matches the external data source type (container path for Azure Blob, bucket path for S3-compatible storage).
Step 3: Validate External Data Source Permissions
- Confirm the SQL Server service account or managed identity has write access to the error file destination.
- Run
SELECT * FROM sys.external_data_sources;to verify the data source referenced inERRORFILE_DATA_SOURCEis correctly configured and reachable. - Check Windows Firewall or network security group rules on Windows Server 2025 if the external storage is not on the local machine.
Step 4: Re-Execute the Statement
- Run the corrected
BULK INSERTorOPENROWSETstatement in SQL Server Management Studio (SSMS) or Azure Data Studio. - Monitor the Messages pane for successful completion or any new error codes.
Alternative or Verification Steps
- Verify success by checking that the specified
ERRORFILE_LOCATIONpath now contains a.logand.log.error.txtfile pair after running a bulk load with intentionally malformed test data. - If the error persists, bypass external data sources entirely by using a local UNC path (e.g.,
\\ServerName\SharedFolder\errors\) for bothERRORFILEandERRORFILE_LOCATIONto isolate whether the issue is permissions-related or syntax-related.