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

Troubleshooting Guide: SQL Server Error 12810

Why This Error Happens

Error 12810 occurs when a T-SQL statement, command-line utility, or configuration script includes the same option or argument more than once within a single command. This is commonly triggered by syntax errors in BACKUP, RESTORE, or CREATE/ALTER statements where a WITH clause option (such as COMPRESSION, CHECKSUM, or STATS) is duplicated. It can also occur when automated scripts, maintenance plans, or third-party backup tools concatenate parameters without validating for duplicates, especially after migration to SQL Server 2025’s updated parser.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Statement

  • Check the SQL Server Error Log or Event Viewer (Windows Logs > Application) for the exact statement that triggered Error 12810.
  • Note the placeholder value %.*ls in the error message — SQL Server will substitute this with the actual duplicated option name at runtime (e.g., “COMPRESSION”, “STATS”, or “NAME”).
  • Use SQL Server Management Studio (SSMS) Activity Monitor or sys.dm_exec_query_stats to trace the query if it originates from an application.

Step 2: Review and Correct the T-SQL Syntax

  • Open the script in SSMS or Azure Data Studio and locate the WITH clause in the command (common in BACKUP DATABASE, RESTORE DATABASE, or CREATE INDEX statements).
  • Manually scan for repeated keywords, for example:
  BACKUP DATABASE [YourDB]
  TO DISK = 'C:\Backups\YourDB.bak'
  WITH COMPRESSION, CHECKSUM, COMPRESSION;
  • Remove the duplicate option, keeping only a single instance of each parameter.

Step 3: Audit Maintenance Plans and Automated Scripts

  • Open SQL Server Agent (in SSMS) and inspect any Maintenance Plans or Jobs under SQL Server Agent > Jobs.
  • Check the generated T-SQL in the Job Step properties (right-click Job Step > Edit > Command) for auto-generated duplicate flags, which often occurs after upgrading maintenance plan templates to SQL Server 2025.
  • If using PowerShell (SqlServer module) or sqlcmd, review scripts for repeated -C, -E, or -S flags passed to the executable.

Step 4: Update or Reinstall Affected Tools

  • If a third-party backup or ETL tool is generating the malformed command, check for a vendor patch compatible with SQL Server 2025’s stricter parser validation.
  • Navigate to C:\Program Files\Microsoft SQL Server\160\DTS\Binn\ (or the relevant version path) and verify SSIS packages aren’t injecting duplicate connection string parameters.
  • Reinstall or update the tool, then re-run the job to confirm the parameter list is clean.

Step 5: Test the Corrected Statement

  • Execute the cleaned-up T-SQL statement directly in SSMS against a test database.
  • Confirm no Error 12810 appears and the operation completes successfully.

Alternative or Verification Steps

  • Run SELECT * FROM sys.messages WHERE message_id = 12810; in SSMS to confirm the exact error text and severity level, ensuring your fix aligns with the expected syntax.
  • If the error persists after correcting the script, enable SQL Server extended events (sqlserver.error_reported) to capture the full raw statement text in real time for deeper inspection.