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

Troubleshooting Guide: SQL Server Error 4895 – “Unicode data is odd byte size for column %d”

Why This Error Happens

Error 4895 occurs when SQL Server encounters Unicode (NVARCHAR/NCHAR/NTEXT) data in a row that has an odd number of bytes, even though Unicode characters must always be stored in even-byte pairs (2 bytes per character using UCS-2/UTF-16 encoding). This is almost always caused by data corruption at the page level—often resulting from a damaged database file, improper restoration from a backup, a failed BCP (Bulk Copy Program) import, or a bulk insert operation that used an incorrect or mismatched collation/format file. In rarer cases, it can stem from a storage-level fault (disk, SAN, or I/O subsystem) that silently altered bytes within a data page.

Step-by-Step Resolution Guide

Step 1: Run a Full Database Consistency Check

  • Open SQL Server Management Studio (SSMS) or a query window connected to the affected instance on Windows Server 2025 / Windows 11.
  • Execute the following command to identify the scope of corruption:
DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;
  • Review the output for allocation or consistency errors tied to the specific table/column referenced in Error 4895.

Step 2: Identify the Offending Table and Bulk Load Source

  • If the error occurred during a BCP or BULK INSERT operation, check the source flat file or format file used:
  • Path example: C:\SQLData\ImportFiles\source_data.txt
  • Confirm the file encoding matches the target column type (e.g., UTF-16LE for NVARCHAR columns).
  • Re-run the import using the -w switch (wide character/Unicode) in BCP:
bcp YourDatabase.dbo.YourTable in "C:\SQLData\ImportFiles\source_data.txt" -w -T -S YourServerName

Step 3: Repair the Corrupted Table or Restore from Backup

  • If DBCC CHECKDB confirms physical corruption, first attempt a targeted repair:
DBCC CHECKTABLE ('YourTableName', REPAIR_REBUILD);
  • If corruption persists or involves critical system pages, restore the database from the last known good backup:
  • Navigate to backup location, e.g., D:\SQLBackups\YourDatabase_FULL.bak
  • Use SSMS “Restore Database” wizard or RESTORE DATABASE T-SQL command with WITH REPLACE.

Step 4: Validate Underlying Storage Health

  • Since odd-byte corruption can originate from disk-level faults, run chkdsk on the volume hosting the .mdf/.ndf files:
chkdsk D: /f /r
  • Check Windows Event Viewer (Event ID 51, 153) for disk or controller errors correlating with the time of corruption.

Alternative or Verification Steps

  • After applying fixes, re-run DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS; and confirm zero allocation/consistency errors are returned.
  • As an alternative, export the affected table from the restored backup into a new table using SELECT INTO with explicit NVARCHAR casting, then swap tables to avoid re-encountering the odd-byte structure in production.