Troubleshooting Guide: SQL Server Error 4802 – SINGLE_LOB Structure Issue
Why This Error Happens
Error 4802 with the “SINGLE_LOB” structure message typically occurs during a BULK INSERT or OPENROWSET(BULK...) operation when SQL Server 2025 encounters an invalid or unsupported data file format specification. This is commonly caused by a mismatched FORMATFILE definition, an incorrect single-column format request against a multi-column source, or file encoding issues (such as UTF-8 BOM markers) that corrupt the data stream. Additionally, insufficient NTFS permissions on the source file for the SQL Server service account can trigger this error when the engine cannot properly validate the LOB (Large Object) structure before import.
Step-by-Step Resolution Guide
Step 1: Validate the Source File and Format Specification
- Open the source file in a hex editor or Notepad++ to check for a Byte Order Mark (BOM) at the beginning of the file.
- Confirm the
SINGLE_CLOB,SINGLE_NCLOB, orSINGLE_BLOBoption matches the actual data type of the file (text vs. binary). - If using a
.fmtformat file, verify the column count and terminators align exactly with the source file structure.
Step 2: Verify File Path Permissions and Accessibility
- Navigate to the folder containing the source file (e.g.,
C:\SQLData\Import\). - Right-click the folder, select Properties > Security, and ensure the SQL Server service account (e.g.,
NT Service\MSSQLSERVER) has Read & Execute permissions. - Run the following command in SQL Server Management Studio (SSMS) to test accessibility:
SELECT * FROM OPENROWSET(BULK 'C:\SQLData\Import\file.txt', SINGLE_CLOB) AS Data;
Step 3: Correct the BULK Import Syntax
- Rewrite the query to explicitly match the required LOB type based on your file’s actual encoding:
SELECT BulkColumn
FROM OPENROWSET(BULK 'C:\SQLData\Import\file.json', SINGLE_NCLOB) AS Import;
- If importing JSON or XML data, ensure you are not mixing
SINGLE_BLOB(binary) with text-based functions likeOPENJSON.
Step 4: Restart the SQL Server Service
- Open Services.msc on Windows Server 2025 / Windows 11.
- Locate SQL Server (MSSQLSERVER), right-click, and select Restart to clear any locked file handles or cached execution plans causing the conflict.
Alternative or Verification Steps
- Re-run the original
BULK INSERTorOPENROWSETquery; if successful, the data should populate without throwing Error 4802. - As an alternative, use SQL Server Import and Export Wizard (accessible via SSMS) to bypass manual T-SQL syntax errors and visually map the file structure instead.