Why This Error Happens
Error 5343 occurs when a BULK INSERT or OPENROWSET statement specifies ROWTERMINATOR and FIELDTERMINATOR/DELIMITER arguments without providing either a WITH clause that defines column schema or enabling schema inference for the flat file. SQL Server 2025’s updated bulk-load parser requires explicit structural context to interpret delimiters correctly, since the engine no longer assumes a default schema for ambiguous file formats. This typically happens after migrating scripts from older SQL Server versions where delimiter-only syntax was still permitted without a formal schema definition.
Step-by-Step Resolution Guide
Step 1: Review the Current Bulk Import Statement
- Open the T-SQL script or stored procedure that triggered Error 5343.
- Check whether the
OPENROWSET(BULK...)orBULK INSERTcommand includes aWITH (...)clause. - Confirm if
FIELDTERMINATOR,ROWTERMINATOR, orDELIMITERare declared without accompanying column definitions.
Step 2: Add an Explicit WITH Clause or Format File
- Modify the statement to include a
WITHclause specifying column names, data types, and ordinal positions, for example:
WITH (col1 INT, col2 VARCHAR(50)) - Alternatively, generate a
.fmtformat file usingbcpwith the-fswitch and reference it viaFORMATFILE = 'C:\SQLData\import.fmt'. - Ensure the format file path is accessible to the SQL Server service account on Windows Server 2025.
Step 3: Enable Schema Inference for Flat Files
- If using
OPENROWSETwithFORMAT = 'CSV', addPARSER_VERSION = '2.0'and setHEADER_ROW = TRUEto allow automatic schema inference. - Confirm the file encoding (UTF-8) and header row are properly formatted, since inference depends on consistent column headers.
- Re-run the query after saving changes to validate that the terminators are now recognized within a defined schema context.
Step 4: Restart SQL Server Service and Clear Plan Cache
- Open SQL Server Configuration Manager on Windows Server 2025 and restart the SQL Server (MSSQLSERVER) service.
- Run
DBCC FREEPROCCACHE;to remove any cached execution plans referencing the old syntax. - Re-execute the corrected bulk import script.
Alternative or Verification Steps
- Run the corrected script in SQL Server Management Studio (SSMS) and confirm the import completes without Error 5343, then validate row counts in the target table.
- If the error persists, test the import using a minimal sample CSV file with a manually defined
WITHclause to isolate whether the issue is file-specific or schema-specific.