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

Why This Error Happens

Error 2343 (“%sUnterminated text section – missing `”) typically occurs when SQL Server 2025 encounters a malformed or corrupted script, batch file, or configuration string where a quoted text block was opened but never properly closed with a matching backtick or delimiter. This often happens due to truncated SQL scripts, encoding mismatches (such as UTF-8 vs ANSI) during file transfer, or corruption introduced by an interrupted write operation on Windows Server 2025. It can also surface when third-party tools or automation scripts generate dynamic T-SQL with improper string escaping.

Step-by-Step Resolution Guide

Step 1: Identify the Source Script or File

  • Open SQL Server Error Logs via SQL Server Management Studio (SSMS) or C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • Locate the exact query, job step, or import file referenced near the Error 2343 entry.
  • Note the file path if the error originates from an external .sql script or PowerShell-invoked batch.

Step 2: Inspect and Repair the Text Encoding

  • Open the offending file in a text editor like Notepad++ or VS Code.
  • Check for an unclosed backtick (`), single quote, or double-quote character near the end of the file or string literal.
  • Save the file explicitly as UTF-8 without BOM to avoid hidden encoding characters that corrupt delimiters.
  • Run sqlcmd -i yourscript.sql -f 65001 to force UTF-8 interpretation during execution.

Step 3: Validate SQL Agent Jobs and Linked Scripts

  • Navigate to SQL Server Agent > Jobs in SSMS and review any job steps that dynamically build T-SQL strings.
  • Check for missing closing characters in concatenated strings, especially in PowerShell or CMD steps calling SQL Server.
  • Update the job step command, ensuring every opened quote or backtick has a corresponding closing character.

Step 4: Rebuild or Restore the Corrupted Object

  • If the error persists on a stored procedure or view definition, script out the object via Generate Scripts in SSMS.
  • Drop and recreate the object using the corrected, properly terminated script.
  • Restart the SQL Server service via services.msc or net stop MSSQLSERVER && net start MSSQLSERVER to clear cached execution plans.

Alternative or Verification Steps

  • Re-run the original script or job step and confirm no Error 2343 appears in the ERRORLOG or Agent Job History.
  • If the issue persists, restore the affected script/object from a known-good backup and re-apply only the necessary changes incrementally to isolate the corrupted section.