SQL Server cannot locate or access the data file specified in a BULK INSERT or BCP command.
“[Microsoft][ODBC Driver 17 for SQL Server] Unable to open BCP host data-file” appears when SQL Server or the BCP utility cannot find or read the file named in a BULK INSERT/BCP command. Verify the full path, correct permissions, and that the SQL Server service account can reach the folder to resolve the error.
[Microsoft][ODBC Driver 17 for SQL Server]Unable to open BCP host data-file
SQL Server raises “[Microsoft][ODBC Driver 17 for SQL Server] Unable to open BCP host data-file” when a BULK INSERT
or bcp
command cannot find, reach, or read the data file you specified. The ODBC driver returns the message before any rows are processed.The error blocks data import or export jobs, delaying ETL pipelines and breaking CI/CD scripts. Fixing it quickly keeps deployments and nightly loads on schedule.
Missing or misspelled file paths trigger the error first. The driver tries to open a non-existent file and immediately fails.Operating-system permission issues are another major cause. The SQL Server service account or the user running bcp
lacks read access to the folder or share.Network shares introduce SMB, DNS, or VPN problems. The path may be correct, but the machine cannot resolve or reach the share.Wrong file encoding like UTF-16LE with no -C
or DATAFILETYPE
option also cause failures, though the error text stays the same.
First, verify the file path is correct and fully qualified. Use UNC paths (e.g., \\server\share\file.csv
) when the file sits on a network share.Second, grant the SQL Server service account or your Windows login Read
permission on the folder. Restart the service if you changed its account.Third, test the path from the SQL Server host with PowerShell Test-Path
or dir
. Confirm the account can list and open the file.Finally, specify the correct code page or data-file type: bcp dbo.Table in file.csv -c -C 65001
or BULK INSERT … WITH (DATAFILETYPE = ‘char’, CODEPAGE = ‘65001’)
.
Local import on developer PC: Supply the full absolute path (no relative paths) and run Command Prompt “as Administrator.”Server import via SQL Agent: Make sure the SQL Agent proxy or service account has share access; map a credential if using EXEC xp_cmdshell 'bcp …'
.Docker/Kubernetes deployments: Mount the host folder into the container and pass the inside-container path to bcp
.
Store import files in a dedicated share with documented ACLs and service accounts.Use UNC paths in all scripts to remain environment-agnostic.Automate permission checks in CI using PowerShell or Bash pre-flight scripts.Adopt a modern SQL editor like Galaxy to centralize and share trusted BULK INSERT
snippets, reducing typo-prone paths.
Msg 4860 “Cannot bulk load because the file could not be opened”: Same root cause but raised inside T-SQL. Fix by granting permissions or correcting paths.“BCP host-files must be imported as character data”: Supply -c
or DATAFILETYPE='char'
.“Operating system error code 5 (Access is denied)”: Grant read/write NTFS and share permissions to the SQL Server account.
Incorrect file path: Typos, relative paths, or wrong working directory cause the driver to fail instantly.
Permission denied: SQL Server service or bcp user lacks NTFS or share read rights.
Network share unavailable: VPN down, DNS not resolving, or firewall blocking SMB ports 445/139.
File locked or in use: Another process keeps an exclusive lock, preventing read.
• Msg 4860: Cannot bulk load because the file could not be opened.• Msg 4832: Bulk load: The user does not have permission to perform this operation.• Operating system error code 5 (Access is denied).• [Microsoft][ODBC Driver] The system cannot find the file specified.
SQL Agent runs under its own service account, which may not have file-share permissions. Grant Read access or use a credential/proxy.
Relative paths rely on the current working directory and often break in automated jobs. Always use absolute or UNC paths.
No, but the SQL Server service account needs network access to the share where the file resides.
Galaxy stores and reuses vetted BULK INSERT
scripts, reducing path typos, and its AI copilot flags missing permissions before execution.