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

Why This Error Happens

Error 8504 typically occurs when SQL Server 2025 attempts to process a distributed or bulk import transaction using a corrupted or mismatched buffer handle, often due to interference from the Microsoft Distributed Transaction Coordinator (MS DTC). This commonly happens when the MSDTC service has restarted mid-transaction, when the import buffer size configured for BCP/BULK INSERT operations exceeds the memory SQL Server can allocate for the transaction, or when network packet fragmentation corrupts the data stream during a remote import. In many cases, this is also triggered by permission conflicts on the temporary storage location used for staging import data.

Step-by-Step Resolution Guide

Step 1: Verify and Restart the MSDTC Service

  • Open Services.msc on Windows Server 2025 / Windows 11.
  • Locate Distributed Transaction Coordinator, right-click, and select Restart.
  • Confirm the service is set to Automatic startup type to prevent future transaction coordination drops.
  • Run msdtc -resetlog from an elevated Command Prompt if the service fails to restart cleanly.

Step 2: Validate the Import File and Buffer Size Settings

  • Check the source file (CSV, BCP native file, etc.) for unexpected EOF characters or truncation using a hex editor.
  • Re-run the import using an explicit batch size parameter to avoid buffer overflow:
  • BULK INSERT YourTable FROM 'C:\Data\import.csv' WITH (BATCHSIZE = 5000, TABLOCK);
  • Reduce the KILOBYTES_PER_BATCH value if importing from a network share rather than local disk.

Step 3: Check File and Folder Permissions

  • Ensure the SQL Server service account (found under SQL Server Configuration Manager) has Read/Write access to the staging folder (e.g., C:\SQLImport\Staging).
  • Grant explicit NTFS permissions via:
  • icacls "C:\SQLImport\Staging" /grant "NT SERVICE\MSSQLSERVER":(OI)(CI)F
  • Disable any third-party antivirus real-time scanning temporarily on the staging directory, as file-locking can corrupt the buffer mid-transfer.

Step 4: Rebuild the Transaction Log and Retry Import

  • If the error persists, back up the current transaction log:
  • BACKUP LOG [YourDatabase] TO DISK = 'C:\Backups\YourDatabase_Log.bak';
  • Shrink and reinitialize the log file to clear any orphaned buffer pointers:
  • DBCC SHRINKFILE (YourDatabase_Log, 1);
  • Retry the import operation in a new, isolated transaction scope.

Alternative or Verification Steps

  • Run DBCC CHECKDB('YourDatabase') WITH NO_INFOMSGS; after the import completes to confirm no corruption remains in the destination tables.
  • If the error recurs only over network shares, switch the import source to local SSD storage temporarily to rule out network packet corruption as the root cause.