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

Troubleshooting Guide: Error 10528 – Invalid Plan Guide Name

Why This Error Happens

Error 10528 occurs when the sp_create_plan_guide stored procedure is executed with a plan guide name that begins with a pound/hash (#) character. SQL Server reserves names beginning with # and ## to denote local and global temporary objects respectively, and this naming convention is strictly enforced even for logical objects like plan guides that are not physically temporary tables. The SQL Server 2025 Query Optimizer rejects the object creation at the parsing stage before any metadata is written to the sys.plan_guides catalog view, as it cannot distinguish the intent between a temporary object reference and a standard identifier.

Step-by-Step Resolution Guide

Step 1: Identify the Offending T-SQL Script

  • Locate the specific script or application module calling sp_create_plan_guide.
  • Search for the @name parameter within the EXEC sp_create_plan_guide block.
  • Use SQL Server Management Studio (SSMS) 21 or Azure Data Studio to open the deployment script in question.

Step 2: Rename the Plan Guide Identifier

  • Remove the leading # or ## characters from the @name string value.
  • Replace the hash symbol with an underscore (_) or a descriptive prefix (e.g., change #MyGuide to PG_MyGuide).
  • Ensure the new name still adheres to standard SQL Server identifier rules (max 128 characters, no reserved keywords).

Step 3: Validate Object Naming Conventions

  • Cross-reference the new name against existing objects in sys.plan_guides to prevent duplicate name conflicts (which would trigger a different error, 10529).
  • If the name must contain special characters, enclose it strictly in square brackets [ ], though this is generally discouraged for Plan Guides.

Step 4: Re-execute the Creation Script

  • Run the corrected sp_create_plan_guide command against the target database using an account with ALTER ANY DATABASE DDL TRIGGER or appropriate sysadmin/db_owner permissions.
  • Open the specific session (SPID) in Activity Monitor to confirm the command completes without a timeout or blocking issue.

Alternative or Verification Steps

  • Verify the Fix: Query the system view using SELECT name, scope_type_desc FROM sys.plan_guides WHERE name = 'YourNewName'; to confirm the object now exists in the database metadata.
  • Alternative Approach: If dynamic SQL is generating this name programmatically, inspect the application’s string concatenation logic (e.g., in a .NET or Python script) to ensure a variable isn’t accidentally prepending a # symbol intended for a different temporary table creation step elsewhere in the code.