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

Troubleshooting Guide: SQL Server Error 4804 – “While Reading Current Row From Host”

Why This Error Happens

Error 4804 typically occurs during a BULK INSERT or BCP (Bulk Copy Program) operation when SQL Server encounters a mismatch between the expected data format and the actual data in the source file. This is commonly caused by a corrupted data file, an incorrect format file (.fmt) specification, or a row terminator/column terminator mismatch that causes the engine to misread row boundaries. In some cases, this also stems from file-level permission issues on Windows Server 2025, preventing the SQL Server service account from reading the host file correctly in a stream.

Step-by-Step Resolution Guide

Step 1: Verify File Permissions and Service Account Access

  • Ensure the SQL Server service account (e.g., NT Service\MSSQLSERVER) has explicit Read and Read & Execute permissions on the source folder.
  • Navigate to the file location via File Explorer, right-click the parent folder > Properties > Security tab to confirm access control lists (ACLs).
  • If running locally, verify the path isn’t blocked by Windows 11 Controlled Folder Access (Ransomware protection) under Windows Security > Virus & threat protection.

Step 2: Validate the Format File and Terminators

  • Open the .fmt file associated with the Bulk Insert/BCP command and verify the field count matches the source table schema exactly.
  • Check for mismatched ROWTERMINATOR and FIELDTERMINATOR values; a common fix is changing \n to \r\n depending on how the source file was generated (Unix vs. Windows).
  • Example T-SQL check:
  BULK INSERT YourTable
  FROM 'C:\Data\source.csv'
  WITH (FORMATFILE = 'C:\Data\format.fmt', ROWTERMINATOR = '\r\n');

Step 3: Inspect the Source Data File for Corruption

  • Open the source file (CSV/TXT) in a raw text editor (like Notepad++) to check for unexpected binary characters, truncated rows, or an inconsistent number of delimiters in the final row.
  • Look specifically at the last line of the file; a missing final row terminator is a frequent trigger for Error 4804.
  • Re-export the source data from the original system (ERP, API, or flat-file export tool) if corruption is confirmed.

Step 4: Check SQL Server Instance Configuration

  • Verify that the MAXERRORS and BATCHSIZE parameters in your bulk operation are set to reasonable values to isolate which specific row is failing.
  • Restart the SQL Server (MSSQLSERVER) service via services.msc if the error persists after a file correction, as stale read-locks on Windows Server 2025 can sometimes cause file-stream artifacts.

Alternative or Verification Steps

  • Verification: Run the BULK INSERT command again with MAXERRORS = 0 to confirm the operation completes without triggering Error 4804, then spot-check the row count in the destination table using SELECT COUNT(*) FROM YourTable;.
  • Alternative Fix: If the error persists, bypass the native client driver by importing the data via SQL Server Import and Export Wizard in SSMS, which often provides a more detailed graphical error log to pinpoint the exact faulty row/column.