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

Troubleshooting Guide: SQL Server Error 4820 — “Cannot bulk load. Unknown version of format file”

Why This Error Happens

This error occurs when SQL Server’s BULK INSERT or bcp utility attempts to read a format file (.fmt) whose version header is missing, corrupted, or not recognized by the SQL Server 2025 engine. It commonly happens when a format file generated by a much older version of bcp (or manually edited incorrectly) is used against a newer server instance, causing a mismatch in the expected header structure. It can also occur if the file encoding is wrong (e.g., saved as Unicode when ANSI is expected, or vice versa), corrupting the first line that declares the format version.

Step-by-Step Resolution Guide

Step 1: Verify the Format File Version Header

  • Open the .fmt file in a plain text editor (Notepad++ recommended over default Notepad to avoid encoding issues).
  • Confirm the very first line contains a valid version number — typically 9.0, 10.0, 14.0, or the current 17.0 for SQL Server 2025.
  • If the first line is blank, contains garbled characters, or shows an unexpected value, the file is corrupted or incompatible.

Step 2: Regenerate the Format File Using the Current bcp Utility

  • Open Command Prompt as Administrator on Windows Server 2025 / Windows 11.
  • Run the following command to regenerate a compatible native format file:
bcp YourDatabase.dbo.YourTable format nul -c -f "C:\BulkData\NewFormat.fmt" -S YourServerInstance -T
  • For XML format files (recommended for SQL Server 2025), use the -x flag:
bcp YourDatabase.dbo.YourTable format nul -x -c -f "C:\BulkData\NewFormat.xml" -S YourServerInstance -T
  • Replace the old file path in your BULK INSERT script with the newly generated file path.

Step 3: Check File Encoding and Line Endings

  • Ensure the format file was not altered by a text editor that changed line endings (CRLF vs LF) or encoding (UTF-8 BOM vs ANSI).
  • Re-save the file explicitly as ANSI or UTF-8 without BOM using Notepad++ (Encoding menu > Convert to ANSI/UTF-8 without BOM).
  • Avoid editing format files in rich text editors like Microsoft Word, which can silently corrupt the header.

Step 4: Update the BULK INSERT or bcp Command Syntax

  • Confirm your T-SQL command correctly references the format file path and uses the matching FORMATFILE argument:
BULK INSERT dbo.YourTable
FROM 'C:\BulkData\datafile.csv'
WITH (
    FORMATFILE = 'C:\BulkData\NewFormat.xml',
    FIRSTROW = 2
);
  • Ensure the SQL Server service account has read permissions on the folder containing both the data file and the format file.

Step 5: Validate SQL Server and bcp Version Alignment

  • Run bcp -v from Command Prompt to confirm the installed bcp utility matches your SQL Server 2025 build.
  • If there’s a mismatch (e.g., an older SQL Server 2016/2019 client tools version installed alongside SQL Server 2025), update the command-line utilities via the SQL Server Installation Center.

Alternative or Verification Steps

  • Re-run the original BULK INSERT or bcp command using the newly regenerated format file and confirm the operation completes without Error 4820.
  • As an alternative, bypass format files entirely by using the WITH (FORMAT = 'CSV') clause (supported in SQL Server 2017+) for simple comma-delimited imports, which eliminates format file version dependencies altogether.