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

Troubleshooting Guide: SQL Server Error 10914 — Invalid Object Name (Begins with # or ##)

Why This Error Happens

This error occurs when a SQL Server object—such as a table, procedure, or variable—is incorrectly named using a single # or double ## prefix outside the context of temporary object creation. SQL Server reserves these prefixes exclusively for local (#) and global (##) temporary tables, so applying them to permanent objects, constraints, or identifiers violates naming rules. This typically stems from a scripting error, a flawed migration script, or an ORM (Object-Relational Mapper) incorrectly generating object names during a schema update.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Script or Query

  • Open SQL Server Management Studio (SSMS) and check the Activity Monitor or SQL Server Logs to locate the exact query that triggered Error 10914.
  • Review the specific T-SQL statement for CREATE TABLE, CREATE PROCEDURE, or DECLARE commands that mistakenly use a # or ## prefix on a permanent object.
  • Run the following command to check recent error logs via PowerShell on Windows Server 2025:
  Get-EventLog -LogName Application -Source "MSSQLSERVER" -Newest 20

Step 2: Correct the Object Naming Convention

  • If the object is intended to be permanent, remove the # or ## prefix entirely from the object name.
  • If the object is intended to be temporary, ensure it is created within a session scope correctly, for example:
  CREATE TABLE #TempTable (ID INT);
  • Check your application’s ORM configuration (e.g., Entity Framework or Hibernate) for naming convention templates that might be auto-generating invalid prefixes.

Step 3: Update Linked Server or Migration Scripts

  • Navigate to your deployment pipeline or migration folder (e.g., C:\DeploymentScripts\SQL\) and search for hardcoded # symbols in .sql files.
  • Use a text editor like VS Code to perform a global search-and-replace for CREATE TABLE # to ensure the syntax matches the intended temporary or permanent scope.
  • Re-deploy the corrected script to the Microsoft SQL Server 2025 instance.

Step 4: Validate Compatibility Level Settings

  • Open SSMS and right-click the database, then select Properties > Options.
  • Verify the Compatibility Level is set appropriately for SQL Server 2025 (Level 170), as older compatibility levels might handle temporary object parsing differently.
  • Apply the changes and restart the SQL Server service via services.msc on Windows Server 2025 if necessary.

Alternative or Verification Steps

  • Verification: Re-run the original script or application transaction that caused the error; confirm that Error 10914 no longer appears in the SQL Server Error Log or the Windows Event Viewer.
  • Alternative: If the error persists in a specific stored procedure, use sp_helptext '[ProcedureName]' to review the exact object definition and manually rename the object using sp_rename, ensuring the new name starts with a standard alphanumeric character.