How to Fix SQL Server Error 10535 (Msg 10535)
You see sql server error 10535 when a target execution plan is missing from cache. To fix it, run the target query again and create the plan guide right away. Database teams use plan guides to shape query behavior without changing app code. When you build a guide from cache, the engine looks for a specific plan. If the engine cannot find that plan, it stops the operation and returns message 10535. Why sql server error 10535 happens in the database engine The official message for sql server e
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You see sql server error 10535 when a target execution plan is missing from cache. To fix it, run the target query again and create the plan guide right away.
Database teams use plan guides to shape query behavior without changing app code. When you build a guide from cache, the engine looks for a specific plan. If the engine cannot find that plan, it stops the operation and returns message 10535.
Why sql server error 10535 happens in the database engine
The official message for sql server error 10535 carries a severity level of 16. It states that the engine cannot create the named plan guide. This happens because no matching plan exists in the plan cache.
The plan cache holds execution plans in memory so the server can reuse them. Still, plans do not stay in memory forever. High memory pressure can push older or less used plans out of the cache. Server restarts and failovers also wipe the entire plan cache clean.
Schema changes on tables or indexes can also invalidate cached plans. Even a small typo in your plan identifier will trigger this error. If you wait too long between finding a plan and creating the guide, the plan disappears. Because severity 16 marks a user error, the database admin must fix the input.
How to diagnose and fix the failure in production
Start by checking if the target query plan still lives in the plan cache. Query the dynamic management views to look up your active cached plans. If the list is empty, the engine already evicted the plan from memory.
To get a fresh plan, run the target workload or query again. Capture the new plan identifier right after the query finishes running. Then, run your plan guide creation steps before memory pressure clears the cache again.
Kubernetes API Server Access + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Keep permissions tight when your team investigates plan cache issues in production. Do not grant the fixed owner role just to let engineers inspect query plans. Members of the owner role can perform all maintenance tasks and drop the database.
Use least privilege when setting up logins and database users for tuning work. A database user represents the identity of a login when it connects to a database. For people who work across many databases, a standard user with a master login works well. For people who need one database, a contained database user is a good option. An admin must first turn on contained databases on the server and database.
How to prevent plan cache misses during query tuning
Timing is the biggest factor when you build plan guides from memory. On busy servers, high query volume pushes single-use plans out of memory fast. Prepare your plan guide script in advance so you only need the fresh plan identifier.
Never run manual cache clearing commands on a live production instance during business hours. Clearing the cache forces every query to compile again and removes your target plan. Schedule plan guide changes during stable traffic windows when memory churn is low.
Also review who can read and change data while you test queries. Members of the fixed data reader role can read all data from user tables and views. If an engineer only needs to test read queries, avoid granting data writer roles. Remember that you cannot change the permissions assigned to fixed database roles.
Add runtime guardrails beside SQL Server
Role grants and network rules are needed setup for SQL Server. Still, an allowed user or agent tool can send a bad delete or read raw customer fields over a valid session. In practice, hoop.dev sits inline in the TDS protocol beside the database as a sidecar for your SQL Server. For every query an agent or human runs in production, hoop.dev decides whether to pass, mask, block, or escalate it for review.
With hoop.dev SQL Server controls, rules refuse banned statements before they run, hold risky queries for human review, and mask matched sensitive values in supported result columns in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for HIPAA, PCI DSS, SOX, and GDPR audits. See the source on GitHub.
Frequently asked questions
What does severity 16 mean for sql server error 10535?
Severity 16 means the error comes from a user request rather than a hardware crash. You can fix it by updating your plan reference without restarting the server.
Why did my execution plan disappear from the plan cache?
The database engine removes plans when memory gets full or when table schemas change. Server restarts and manual cache flushes also clear all stored plans from memory.
Can I create a plan guide without using the plan cache?
Yes, you can define a plan guide by writing the exact query text and hints. This method does not rely on a cached plan staying in server memory.
Related guides
In this post