我在 SSMS 中打开一个新窗口并运行以下命令:
SET ANSI_DEFAULTS ON
GO
CREATE PROCEDURE [dbo].[zzz_test2]
(
@a int
)
AS
SET NOCOUNT ON
SET @a=1
RETURN 0
GO
然后关闭窗口,这会导致此警告:
存在未提交的事务。您希望在关闭窗口之前提交这些内容吗?
这是怎么回事?
当我打开一个新的 SSMS 窗口并运行此命令时:
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[zzz_test2]
(
@a int
)
AS
SET NOCOUNT ON
SET @a=1
RETURN 0
GO
然后关闭窗口,我没有收到任何警告。
最佳答案
如described in the documentation对于 ANSI_DEFAULTS
When enabled (ON), this option enables the following ISO settings:
SET ANSI_NULLS
SET CURSOR_CLOSE_ON_COMMIT
SET ANSI_NULL_DFLT_ON
SET IMPLICIT_TRANSACTIONS
SET ANSI_PADDING
SET QUOTED_IDENTIFIER
SET ANSI_WARNINGS
据记录here当 IMPLICIT_TRANSACTIONS
开启时。
Transactions that are automatically opened as the result of this setting being ON must be explicitly committed or rolled back by the user at the end of the transaction
关于sql-server - 错误: There are uncommitted transactions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5378357/