The ODBC driver cannot locate or access the data file referenced in a BULK INSERT or bcp command.
“[Microsoft][ODBC Driver 17 for SQL Server] Unable to open BCP host data-file” signals that SQL Server’s ODBC driver cannot find, reach, or read the file named in your BULK INSERT/bcp statement. Correct the file path, ensure file-system permissions, and verify the file exists to resolve the issue.
[Microsoft][ODBC Driver 17 for SQL Server] Unable to open BCP host data-file
The error is raised by the ODBC Driver 17 for SQL Server when a BULK INSERT, OPENROWSET(BULK …), or the bcp utility cannot open the data file supplied as its data source. The driver stops the bulk-copy operation immediately.
The message usually appears on Windows, Linux, and macOS systems that rely on the Microsoft ODBC or msodbcsql17 driver.
Although the wording is generic, the root cause is always an inaccessible file.
Incorrect or relative file paths lead the driver to look in the wrong directory, resulting in a file-not-found condition.
Insufficient file-system permissions prevent the SQL Server service account or local user from reading the file even when the path is correct.
File locks, antivirus software, or network share issues can keep the file from being opened in read mode.
Unsupported file encodings, line endings, or BOM markers may cause the driver to assume the file is corrupt and refuse to open it.
First, verify the absolute path of the data file, including drive letter on Windows or full mount point on Linux.
Use \Server\Share\file.dat for UNC paths.
Grant READ permissions on the file and its directory to the SQL Server service account or the account running the bcp command. On Linux, run chmod 644 file.dat and chown mssql:mssql file.dat for the mssql user.
Move the file to a local disk if the network share is unstable.
Temporarily disable antivirus scanning to confirm it is not blocking file access.
Open the file in a text editor and ensure the encoding (UTF-8 or ANSI) matches the FORMAT or code-page parameter in your BULK INSERT/bcp options.
When using Azure Data Studio or Galaxy, specify an absolute path in the BULK INSERT statement to avoid environment-relative lookups.
If bcp runs in a CI pipeline, mount the data directory inside the container and reference the inside path, e.g., /app/data/file.csv.
For Dockerized SQL Server on Linux, map the host folder as a volume, then grant mssql user permissions.
Store bulk-load files in a dedicated, access-controlled folder that the SQL Server service account owns.
Automate permission checks in deployment scripts using icacls (Windows) or chmod/chown (Linux).
Validate file existence with xp_fileexist or PowerShell Test-Path before running BULK INSERT or bcp.
“Cannot bulk load because the file could not be opened” appears within SQL Server itself and shares identical root causes—apply the same fixes.
“Operating system error code 5 (Access is denied)” indicates a permission problem; add READ rights to the file.
“BCP host-files must contain at least one row” means the file opened but was empty—verify the export process.
No, but remote paths must be accessible to the service account and stay online throughout the bulk-copy operation.
Relative paths resolve to the SQL Server start-up directory. Always use absolute paths to avoid surprises.
Use OPENROWSET with the BULK option and STORAGE_ACCOUNT_CREDENTIAL along with a proper SAS token.
Galaxy’s SQL editor validates file paths in BULK INSERT/bcp commands, highlights missing tokens, and surfaces permission hints before execution, reducing runtime errors.