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

Troubleshooting Guide: SQL Server Error 4862 – Bulk Load File Incomplete or Unreadable

Why This Error Happens

This error typically occurs when SQL Server’s service account lacks the necessary NTFS read permissions on the source file or its containing directory, preventing the BULK INSERT or BCP operation from accessing the data. It can also result from the file being locked by another process, residing on a network path that SQL Server cannot resolve, or being physically corrupted or truncated during transfer. Additionally, the accompanying “Operating system error code” often points to a Win32 API failure (such as error 5 for Access Denied or error 3 for Path Not Found) that provides the real root cause.

Step-by-Step Resolution Guide

Step 1: Verify NTFS and Share Permissions

  • Right-click the source file (e.g., C:\ImportData\sales.csv) and navigate to Properties > Security.
  • Ensure the SQL Server service account (e.g., NT Service\MSSQLSERVER or your custom domain service account) has at least Read & Execute permissions.
  • If the file resides on a network share, verify the share-level permissions in addition to NTFS permissions, as both are enforced independently.
  • Run icacls "C:\ImportData\sales.csv" in an elevated Command Prompt to audit current permission entries.

Step 2: Decode the Operating System Error Code

  • Check the specific numeric code reported alongside Error 4862 (e.g., “Operating system error code 5”).
  • Open Command Prompt and run net helpmsg 5 (replace 5 with your actual code) to translate it into a human-readable description.
  • Common codes include 3 (The system cannot find the path specified), 5 (Access is denied), and 32 (The process cannot access the file because it is being used by another process).

Step 3: Validate File Path and Network Accessibility

  • If using a UNC path (e.g., \\FileServer\Imports\data.csv), confirm SQL Server can resolve it by testing connectivity from the SQL Server machine itself, not just your local workstation.
  • Avoid using mapped network drives (e.g., Z:\) in your T-SQL script, as SQL Server service sessions often cannot see drive mappings created by a user’s interactive logon; use the full UNC path instead.
  • Ensure the SMB/CIFS firewall ports (TCP 445) are open between the SQL Server host and the file server if applicable.

Step 4: Check File Integrity and Locks

  • Use Handle.exe (Sysinternals) or Resource Monitor to check if another application or antivirus scanner has an active lock on the file.
  • Verify the file size matches the expected source size to rule out a truncated or incomplete file transfer (e.g., an FTP job that terminated early).
  • Temporarily disable real-time antivirus scanning on the import directory to rule out interference, then re-attempt the bulk load.

Step 5: Restart the SQL Server Service to Clear Cached Handles

  • Open Services.msc on Windows Server 2025.
  • Locate SQL Server (MSSQLSERVER) or your named instance, right-click, and select Restart.
  • This clears any stale file handles or cached security tokens that might be causing the service to retain outdated permission data.

Alternative or Verification Steps

  • Verify the Fix: Re-run the BULK INSERT or BCP command and confirm the rows import successfully; check sys.dm_exec_requests to ensure no blocking locks remain on the resource.
  • Alternative Approach: If permissions remain problematic, copy the source file locally to a folder explicitly granted to the SQL Server service account (e.g., C:\SQLImports\) rather than relying on network share permissions, as local NTFS ACLs are easier to troubleshoot and verify.