How to fix Error 5359 on Windows Server 2025 / Windows 11

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 INSERT or OPENROWSET command containing the ERRORFILE_DATA_SOURCE clause.
  • Confirm whether ERRORFILE_LOCATION is missing entirely or commented out.

Step 2: Add the ERRORFILE_LOCATION Parameter

  • Insert a valid ERRORFILE_LOCATION value immediately alongside ERRORFILE_DATA_SOURCE in 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 in ERRORFILE_DATA_SOURCE is 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 INSERT or OPENROWSET statement 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_LOCATION path now contains a .log and .log.error.txt file 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 both ERRORFILE and ERRORFILE_LOCATION to isolate whether the issue is permissions-related or syntax-related.