错误:有未提交的事务 [英] Error: There are uncommitted transactions

查看:40
本文介绍了错误:有未提交的事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SSMS 中打开一个新窗口并运行:

设置 ANSI_DEFAULTS ON走创建程序 [dbo].[zzz_test2](@一个整数)作为设置无计数设置@a=1返回 0走

然后关闭窗口,这会导致此警告:

有未提交的事务.你想在关闭窗口之前提交这些吗?

这是怎么回事??

当我打开一个新的 SSMS 窗口并运行它时:

设置 ANSI_NULLS ON走创建程序 [dbo].[zzz_test2](@一个整数)作为设置无计数设置@a=1返回 0走

关闭窗口,我没有收到警告.

解决方案

文档中所述 用于 ANSI_DEFAULTS

<块引用>

启用 (ON) 时,此选项启用以下 ISO 设置:

SET ANSI_NULLS设置 CURSOR_CLOSE_ON_COMMIT设置 ANSI_NULL_DFLT_ON设置 IMPLICIT_TRANSACTIONS设置 ANSI_PADDINGSET QUOTED_IDENTIFIER设置 ANSI_警告

此处所述,当IMPLICIT_TRANSACTIONS 开启时.><块引用>

自动交易由于此设置而打开ON 必须明确提交或者最后由用户回滚交易的

I open a new window in SSMS and run this:

SET ANSI_DEFAULTS ON 
GO

CREATE PROCEDURE [dbo].[zzz_test2]
(
    @a    int
)
AS
    SET NOCOUNT ON
    SET @a=1
    RETURN 0
GO

and then close the window, which results in this warning:

There are uncommitted transactions. Do you wish to commit these before closing the window?

what is going on??

when I open a new SSMS window and run this:

SET ANSI_NULLS  ON  
GO    

CREATE PROCEDURE [dbo].[zzz_test2]
(
    @a    int
)
AS
    SET NOCOUNT ON
    SET @a=1
    RETURN 0
GO

and close the window, I get no warning.

解决方案

As described in the documentation for 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

As documented here when IMPLICIT_TRANSACTIONS is on.

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

这篇关于错误:有未提交的事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆