Troubleshooting Guide: SQL Server Error 5355
Why This Error Happens
Error 5355 occurs when SQL Server’s BULK INSERT or OPENROWSET(BULK…) operation receives an empty string (”) for a format-related option—such as FIELDTERMINATOR, ROWTERMINATOR, or FORMATFILE—when the specified data format (CSV, native, or JSON) and PARSERVERSION require a non-empty value. This is typically caused by dynamically generated SQL scripts, ETL tools, or ORM frameworks that pass blank variables instead of NULL or a valid delimiter. It can also surface after migrating scripts to PARSERVERSION=’2.0′, which enforces stricter validation on format options than the legacy parser.
Step-by-Step Resolution Guide
Step 1: Identify the Offending Statement and Option
- Check the SQL Server error log or SSMS output for the exact option name referenced in the error message (e.g., FIELDTERMINATOR, ROWTERMINATOR, FORMATFILEDATASOURCE).
- Run the failing query manually in SSMS to isolate which parameter is being passed as an empty string.
- Review any stored procedures or application code that constructs the BULK INSERT/OPENROWSET statement dynamically, especially string concatenation logic.
Step 2: Correct the Parameter Values
- Replace empty string assignments with valid values or NULL. For example:
BULK INSERT dbo.MyTable
FROM 'C:\Data\import.csv'
WITH (
FORMAT = 'CSV',
FIELDTERMINATOR = ',', -- must not be ''
ROWTERMINATOR = '\n',
PARSER_VERSION = '2.0'
);
- If the application passes variables, ensure default values in config files (e.g.,
appsettings.jsonor.env) are not blank strings for delimiter/terminator fields. - For FORMATFILE-based imports, verify the path (e.g.,
C:\SQLData\FormatFiles\import.fmt) is correctly populated and not an empty path variable.
Step 3: Validate PARSER_VERSION Compatibility
- If using PARSER_VERSION = ‘2.0’, confirm all required options for CSV format are explicitly set, since the 2.0 parser does not fall back to defaults like the legacy ‘1.0’ parser.
- Temporarily test with PARSER_VERSION = ‘1.0’ to confirm whether the issue is version-specific.
- Update documentation or templates used by developers to include mandatory non-empty values for all format-related clauses.
Step 4: Rebuild and Test the Import Script
- Clear any cached execution plans related to the procedure using
DBCC FREEPROCCACHE(only in non-production environments) to ensure the corrected script is used. - Re-run the BULK INSERT/OPENROWSET command from SSMS or via the Windows Server 2025 task scheduler job to confirm success.
Alternative or Verification Steps
- Verify the fix by re-executing the import with
SET STATISTICS IO ON;and confirming zero errors insys.dm_exec_requestsor the SQL error log. - If the error persists, bypass dynamic parameter injection entirely and hardcode a known-good FORMATFILE (.fmt) to confirm whether the issue lies in file-based configuration versus inline T-SQL options.