Skip to content

Commit a31ae04

Browse files
Merge pull request #27197 from rwestMSFT/rw-0525-fix-8959
Refresh disallow-triggers option and include PR 8959
2 parents 714f405 + 29e8b00 commit a31ae04

1 file changed

Lines changed: 66 additions & 38 deletions

File tree

Lines changed: 66 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,66 @@
1-
---
2-
title: "disallow results from triggers Server Configuration Option"
3-
description: "Learn about the 'disallow results from triggers' option. See how it can prevent problems in applications that aren't designed to work with result sets."
4-
author: rwestMSFT
5-
ms.author: randolphwest
6-
ms.date: "03/02/2017"
7-
ms.service: sql
8-
ms.subservice: configuration
9-
ms.topic: conceptual
10-
helpviewer_keywords:
11-
- "triggers [SQL Server], result sets"
12-
- "result sets [SQL Server], triggers"
13-
- "disallow results from triggers option"
14-
---
15-
# disallow results from triggers Server Configuration Option
16-
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
17-
18-
Use the **disallow results from triggers** option to control whether triggers return result sets. Triggers that return result sets may cause unexpected behavior in applications that are not designed to work with them.
19-
20-
> [!IMPORTANT]
21-
> [!INCLUDE[ssNoteDepFutureAvoid](../../includes/ssnotedepfutureavoid-md.md)] We recommend that you set this value to 1.
22-
23-
When set to 1, the **disallow results from triggers** option is set to ON. The default setting for this option is 0 (OFF). If this option is set to 1 (ON), any attempt by a trigger to return a result set fails, and the user receives the following error message:
24-
25-
"Msg 524, Level 16, State 1, Procedure \<Procedure Name>, Line \<Line#>
26-
27-
"A trigger returned a resultset and the server option 'disallow_results_from_triggers' is true."
28-
29-
The **disallow results from triggers** option is applied at the [!INCLUDE[msCoName](../../includes/msconame-md.md)] [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] instance level, and it will determine behavior for all existing triggers within the instance.
30-
31-
The **disallow results from triggers** option is an advanced option. If you are using the **sp_configure** system stored procedure to change the setting, you can change disallow results from triggers only when **show advanced options** is set to 1. The setting takes effect immediately without a server restart.
32-
33-
## See Also
34-
[RECONFIGURE &#40;Transact-SQL&#41;](../../t-sql/language-elements/reconfigure-transact-sql.md)
35-
[Server Configuration Options &#40;SQL Server&#41;](../../database-engine/configure-windows/server-configuration-options-sql-server.md)
36-
[sp_configure &#40;Transact-SQL&#41;](../../relational-databases/system-stored-procedures/sp-configure-transact-sql.md)
37-
38-
1+
---
2+
title: "disallow results from triggers (server configuration option)"
3+
description: "Learn about the 'disallow results from triggers' option. See how it can prevent problems in applications that aren't designed to work with result sets."
4+
author: rwestMSFT
5+
ms.author: randolphwest
6+
ms.date: 05/25/2023
7+
ms.service: sql
8+
ms.subservice: configuration
9+
ms.topic: conceptual
10+
helpviewer_keywords:
11+
- "triggers [SQL Server], result sets"
12+
- "result sets [SQL Server], triggers"
13+
- "disallow results from triggers option"
14+
---
15+
# disallow results from triggers (server configuration option)
16+
17+
[!INCLUDE [SQL Server](../../includes/applies-to-version/sqlserver.md)]
18+
19+
Use the **disallow results from triggers** option to control whether triggers return result sets. Triggers that return result sets may cause unexpected behavior in applications that aren't designed to work with them.
20+
21+
> [!IMPORTANT]
22+
> The ability to return result sets from triggers will be removed in a future version of [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)]. Avoid returning result sets from triggers in new development work, and plan to modify applications that currently do this. To prevent triggers from returning result sets, change the disallow results from triggers option to a value of `1`. The default setting for the disallow results from triggers option will be set to `1` in a future version of [!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)].
23+
24+
When set to `1`, the **disallow results from triggers** option is set to `ON`. The default setting for this option is `0` (`OFF`). If this option is set to `1` (`ON`), any attempt by a trigger to return a result set fails, and the user receives the following error message:
25+
26+
```output
27+
Msg 524, Level 16, State 1, Procedure <Procedure Name>, Line <Line#>
28+
29+
A trigger returned a resultset and the server option 'disallow_results_from_triggers' is true.
30+
```
31+
32+
The **disallow results from triggers** option is applied at the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] instance level, and it determines behavior for all existing triggers within the instance.
33+
34+
The **disallow results from triggers** option is an advanced option. If you are using the `sp_configure` system stored procedure to change the setting, you can change disallow results from triggers only when **show advanced options** is set to `1`. The setting takes effect immediately without a server restart.
35+
36+
You can check if the option is set correctly using the following Transact-SQL code:
37+
38+
```sql
39+
-- Check the current value for the option
40+
SELECT [name], value_in_use
41+
FROM sys.configurations
42+
WHERE [name] LIKE 'disallow results from triggers';
43+
44+
-- Set the disallow results from triggers option to 1. This is an advanced option so that must be enabled first
45+
EXEC sp_configure 'show advanced options', 1;
46+
RECONFIGURE;
47+
GO
48+
49+
-- Set the disallow results from triggers option
50+
EXEC sp_configure 'disallow results from triggers', 1;
51+
EXEC sp_configure 'show advanced options', 0;
52+
RECONFIGURE
53+
GO
54+
55+
-- Validate that the option is set to 1
56+
SELECT [name], value_in_use
57+
FROM sys.configurations
58+
WHERE [name] LIKE 'disallow results from triggers';
59+
GO
60+
```
61+
62+
## See also
63+
64+
- [RECONFIGURE (Transact-SQL)](../../t-sql/language-elements/reconfigure-transact-sql.md)
65+
- [Server Configuration Options (SQL Server)](../../database-engine/configure-windows/server-configuration-options-sql-server.md)
66+
- [sp_configure (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-configure-transact-sql.md)

0 commit comments

Comments
 (0)