Skip to content

Commit e43d5d3

Browse files
authored
Merge pull request #34717 from rwestMSFT/rw-0716-fix-34283
Refresh Error 2814 article and add query (PR 34283)
2 parents 3b60d2a + 4c602c4 commit e43d5d3

File tree

1 file changed

+81
-64
lines changed

1 file changed

+81
-64
lines changed

docs/relational-databases/errors-events/mssqlserver-2814-database-engine-error.md

Lines changed: 81 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,91 @@ title: "MSSQLSERVER_2814"
33
description: "MSSQLSERVER_2814"
44
author: MashaMSFT
55
ms.author: mathoma
6-
ms.date: "07/11/2017"
6+
ms.reviewer: randolphwest
7+
ms.date: 07/16/2025
78
ms.service: sql
89
ms.subservice: supportability
910
ms.topic: "reference"
1011
helpviewer_keywords:
1112
- "2814 (Database Engine error)"
1213
---
1314
# MSSQLSERVER_2814
14-
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
15-
16-
## Details
17-
18-
| Attribute | Value |
19-
| :-------- | :---- |
20-
|Product Name|SQL Server|
21-
|Event ID|2814|
22-
|Event Source|MSSQLSERVER|
23-
|Component|SQLEngine|
24-
|Symbolic Name|PR_POSSIBLE_INFINITE_RECOMPILE|
25-
|Message Text|A possible infinite recompile was detected for SQLHANDLE %hs, PlanHandle %hs, starting offset %d, ending offset %d. The last recompile reason was %d.|
26-
27-
## Explanation
28-
One or more statements caused the query batch to recompile at least 50 times. The specified statement should be corrected to avoid further recompilations.
29-
30-
The following table lists the reasons for recompilation.
31-
32-
|Reason code|Description|
33-
|---------------|---------------|
34-
|1|Schema changed|
35-
|2|Statistics changed|
36-
|3|Deferred compile|
37-
|4|Set option changed|
38-
|5|Temp table changed|
39-
|6|Remote rowset changed|
40-
|7|For Browse permissions changed|
41-
|8|Query notification environment changed|
42-
|9|Partition view changed|
43-
|10|Cursor options changed|
44-
|11|Option (recompile) requested|
45-
|12|Parameterized plan flushed|
46-
|13|Test plan linearization|
47-
|14|Plan affecting database version changed|
48-
|15|Query Store plan forcing policy changed|
49-
|16|Query Store plan forcing failed|
50-
|17|Query Store missing the plan|
51-
|18|Interleaved execution required recompilation|
52-
|19|Not a recompile|
53-
|20|Query Store hints changed|
54-
55-
## User Action
56-
57-
1. View the statement causing the recompilation by running the following query. Replace the *sql_handle*, *starting_offset*, *ending_offset*, and *plan_handle* placeholders with the values specified in the error message. The **database_name** and **object_name** columns are NULL for ad hoc and prepared [!INCLUDE[tsql](../../includes/tsql-md.md)] statements.
58-
59-
```sql
60-
SELECT DB_NAME(st.dbid) AS database_name,
61-
OBJECT_NAME(st.objectid) AS object_name,
62-
st.text
63-
FROM sys.dm_exec_query_stats AS qs
64-
CROSS APPLY sys.dm_exec_sql_text (0x01000600B74C2A1300D2582A2100000000000000000000000000000000000000000000000000000000000000 /* replace the 0x01000600B... value with the actual sql_handle*/) AS st
65-
WHERE qs.statement_start_offset = 123 /*replace 123 with actual starting_offset value*/
66-
AND qs.statement_end_offset = 456 /*replace 456 with actual ending_offset value*/
67-
AND qs.plan_handle = 0x06000100A27E7C1FA821B10600 /*replace 0x06000100A27E7C1FA821B10600with actual plan_handle value*/;
68-
```
69-
70-
2. Based on the reason code description, modify the statement, batch, or procedure to avoid recompilations. For example, a stored procedure may contain one or more SET statements. These statements should be removed from the procedure. For additional examples of recompilation causes and resolutions, see [Batch Compilation, Recompilation, and Plan Caching Issues in SQL Server 2005](/previous-versions/sql/sql-server-2005/administrator/cc966425(v=technet.10)).
71-
72-
3. If the problem persists, contact Microsoft Customer Support Services.
73-
74-
## See Also
75-
[SQL:StmtRecompile Event Class](../event-classes/sql-stmtrecompile-event-class.md)
76-
15+
16+
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
17+
18+
## Details
19+
20+
| Attribute | Value |
21+
| :--- | :--- |
22+
| Product Name | SQL Server |
23+
| Event ID | 2814 |
24+
| Event Source | MSSQLSERVER |
25+
| Component | SQLEngine |
26+
| Symbolic Name | PR_POSSIBLE_INFINITE_RECOMPILE |
27+
| Message Text | A possible infinite recompile was detected for SQLHANDLE %hs, PlanHandle %hs, starting offset %d, ending offset %d. The last recompile reason was %d. |
28+
29+
## Explanation
30+
31+
One or more statements caused the query batch to recompile at least 50 times. The specified statement should be corrected to avoid further recompilations.
32+
33+
The following table lists the reasons for recompilation.
34+
35+
| Reason code | Description |
36+
| --- | --- |
37+
| 1 | Schema changed |
38+
| 2 | Statistics changed |
39+
| 3 | Deferred compile |
40+
| 4 | Set option change |
41+
| 5 | Temp table changed |
42+
| 6 | Remote rowset changed |
43+
| 7 | For browse permissions changed |
44+
| 8 | Query notification environment changed |
45+
| 9 | PartitionView changed |
46+
| 10 | Cursor options changed |
47+
| 11 | Option (recompile) requested |
48+
| 12 | Parameterized plan flushed |
49+
| 13 | Test plan linearization |
50+
| 14 | Plan affecting database version changed |
51+
| 15 | Query Store plan forcing policy changed |
52+
| 16 | Query Store plan forcing failed |
53+
| 17 | Query Store missing the plan |
54+
| 18 | Interleaved execution required recompilation |
55+
| 19 | Not a recompile |
56+
| 20 | Query Store hints changed |
57+
| 21 | Query Store hints application failed |
58+
| 22 | Query Store recompiling to capture cursor query |
59+
| 23 | Recompiling to clean up the multiplan dispatcher plan |
60+
61+
To view all compilation codes, run the following dynamic management view query:
62+
63+
```sql
64+
SELECT * FROM sys.dm_xe_map_values
65+
WHERE name LIKE '%compile%cause%';
66+
```
67+
68+
## User action
69+
70+
1. View the statement causing the recompilation by running the following query. Replace the *sql_handle*, *starting_offset*, *ending_offset*, and *plan_handle* placeholders with the values specified in the error message. The `database_name` and `object_name` columns are `NULL` for ad hoc and prepared [!INCLUDE [tsql](../../includes/tsql-md.md)] statements.
71+
72+
```sql
73+
SELECT DB_NAME(st.dbid) AS database_name,
74+
OBJECT_NAME(st.objectid) AS object_name,
75+
st.text
76+
FROM sys.dm_exec_query_stats AS qs
77+
CROSS APPLY sys.dm_exec_sql_text(0x01000600B74C2A1300D2582A2100000000000000000000000000000000000000000000000000000000000000
78+
/* replace the 0x01000600B... value with the actual sql_handle */
79+
) AS st
80+
WHERE qs.statement_start_offset = 123 /* replace 123 with actual starting_offset value */
81+
AND qs.statement_end_offset = 456 /* replace 456 with actual ending_offset value */
82+
AND qs.plan_handle = 0x06000100A27E7C1FA821B10600; /* replace 0x06000100A27E7C1FA821B10600 with actual plan_handle value */
83+
```
84+
85+
1. Based on the reason code description, modify the statement, batch, or procedure to avoid recompilations. For example, a stored procedure might contain one or more `SET` statements. These statements should be removed from the procedure.
86+
87+
For more examples of recompilation causes and resolutions, see [Batch Compilation, Recompilation, and Plan Caching Issues in SQL Server 2005](/previous-versions/sql/sql-server-2005/administrator/cc966425(v=technet.10)). For more information on recompilations, see [Recompile execution plans](../query-processing-architecture-guide.md#recompiling-execution-plans).
88+
89+
1. If the problem persists, contact Microsoft Customer Support Services.
90+
91+
## Related content
92+
93+
- [SQL:StmtRecompile Event Class](../event-classes/sql-stmtrecompile-event-class.md)

0 commit comments

Comments
 (0)