Troubleshooting Guide: SQL Server Error 4843 — Bulk Data Source Provider String Syntax Error
Why This Error Happens
Error 4843 occurs when the BULK INSERT or OPENROWSET(BULK...) statement contains a malformed provider string, typically caused by incorrect syntax in the FORMATFILE, DATA_SOURCE, or format specification arguments. This is often the result of manually editing a query, copy-pasting from an incompatible source (introducing hidden characters), or using an unsupported character/delimiter in the path string. It can also happen when a format file (XML or non-XML) referenced in the bulk operation is corrupted or has been edited with an incompatible text encoding.
Step-by-Step Resolution Guide
Step 1: Inspect and Correct the T-SQL Syntax
- Open the exact query that triggered the error and locate the character position referenced in the error message (
%d). - Check for unescaped single quotes, missing commas, or malformed bracket/parenthesis pairing in the
BULK INSERTorOPENROWSETclause. - Rewrite the query manually in SQL Server Management Studio (SSMS) rather than pasting from Word or web sources, as hidden Unicode characters (like smart quotes
’vs') commonly trigger this error. - Example of a clean syntax reference:
BULK INSERT dbo.TargetTable
FROM 'C:\Data\import.csv'
WITH (
FORMATFILE = 'C:\Data\import.fmt',
FIRSTROW = 2
);
Step 2: Validate the Format File Integrity
- Navigate to the format file location (commonly stored under
C:\SQLData\Formats\or a custom ETL directory). - Open the
.fmtor.xmlformat file in a plain text editor (Notepad++ recommended over standard Notepad) to check for corruption or invalid XML tags. - Regenerate the format file using the
bcputility if corruption is suspected:
bcp YourDatabase.dbo.YourTable format nul -c -f C:\Data\import.fmt -S YourServerName -T
- Ensure there are no extra spaces or line breaks inside the connection string parameters.
Step 3: Verify Provider and Permissions Configuration
- Confirm that
Ad Hoc Distributed Queriesis enabled if usingOPENROWSET, via SQL Server Configuration Manager or using the following script:
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
- On Windows Server 2025 / Windows 11, verify that the SQL Server service account has Read permissions on the target folder (Right-click folder → Properties → Security tab).
- Restart the SQL Server (MSSQLSERVER) service via
services.mscafter making configuration changes.
Step 4: Re-run the Bulk Operation in Isolation
- Strip the query down to the minimum required clause (just
FROMand the file path) and execute it alone to confirm the base path syntax is valid. - Incrementally add back
WITHoptions (FORMATFILE,FIRSTROW,TABLOCK) one at a time to isolate which specific parameter is causing the parser failure.
Alternative or Verification Steps
- Run
SELECT * FROM sys.dm_exec_query_statscross-referenced with recent query text to confirm the corrected statement executes without Error 4843 appearing in the SQL Server Error Log (Management → SQL Server Logsin SSMS). - If the error persists, bypass the format file entirely by using simplified
BULK INSERTsyntax with inline field/row terminators (e.g.,FIELDTERMINATOR = ',',ROWTERMINATOR = '\n') instead of referencing an external.fmtfile.