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

Troubleshooting Guide: SQL Server Error 4130 – Duplicate Hint Specified for BULK Rowset

Why This Error Happens

This error occurs when an OPENROWSET(BULK...) statement contains the same hint (such as FORMATFILE, SINGLE_BLOB, SINGLE_CLOB, or CODEPAGE) specified more than once within the same query. SQL Server’s parser rejects the query because each hint is only allowed to appear a single time per BULK rowset definition. This is typically caused by manually written or auto-generated T-SQL scripts (often from legacy migration tools or copy-pasted templates) that inadvertently duplicate a hint clause, rather than being related to permissions or server configuration.

Step-by-Step Resolution Guide

Step 1: Locate the Offending Query

  • Open the query that triggered Error 4130 in SQL Server Management Studio (SSMS) on your Windows Server 2025 or Windows 11 workstation.
  • Check the SQL Server Error Log (via EXEC sp_readerrorlog; or SSMS > Management > SQL Server Logs) to confirm the exact batch and session that raised Error 4130.

Step 2: Inspect the OPENROWSET(BULK…) Syntax

  • Carefully review the WITH clause of your OPENROWSET(BULK 'filepath', ...) statement.
  • Look specifically for repeated hints, for example:
  SELECT * FROM OPENROWSET(BULK 'C:\Data\import.csv', 
      SINGLE_CLOB, 
      CODEPAGE = '65001',
      CODEPAGE = '1252') AS Data;  -- Duplicate CODEPAGE hint
  • Identify which hint (FORMATFILE, CODEPAGE, ERRORFILE, ROWS_PER_BATCH, SINGLE_BLOB, SINGLE_CLOB, SINGLE_NCLOB) is listed twice.

Step 3: Remove the Duplicate Hint

  • Delete the redundant hint entry, keeping only one instance of each valid hint.
  • Corrected example:
  SELECT * FROM OPENROWSET(BULK 'C:\Data\import.csv', 
      SINGLE_CLOB, 
      CODEPAGE = '65001') AS Data;
  • If the query was generated by an ETL tool (SSIS, Azure Data Factory, or a custom script), check the template or mapping configuration that produced the duplicate hint and correct the source generator logic.

Step 4: Validate File Path and Format File References

  • Ensure the FORMATFILE path (if used) points to a single valid .xml or .fmt file and is not referenced twice under different hint names.
  • Confirm the SQL Server service account has read access to the file path, e.g., C:\ImportFiles\, via Properties > Security in Windows Explorer.

Step 5: Re-run and Monitor the Query

  • Execute the corrected query in SSMS or via sqlcmd on Windows Server 2025.
  • Monitor the SQL Server Error Log again to confirm Error 4130 no longer appears.

Alternative or Verification Steps

  • Run the corrected OPENROWSET(BULK...) query in a test database first and confirm it returns results without throwing Error 4130.
  • If the error persists, use sys.dm_exec_requests and sys.dm_exec_sql_text to capture the exact live query text being executed by an application layer (e.g., SSIS package or .NET app) to rule out a hidden duplicate hint injected at runtime.