错误:有未提交的事务

时间:2011-03-21 13:39:36

标签: sql-server sql-server-2005 tsql

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

SET ANSI_DEFAULTS ON 
GO

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

然后关闭窗口,这会产生此警告:

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

发生了什么事?

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

SET ANSI_NULLS  ON  
GO    

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

关闭窗口,我没有收到任何警告。

1 个答案:

答案 0 :(得分:8)

ANSI_DEFAULTS的{​​{3}}

  

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

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

IMPLICIT_TRANSACTIONS开启时记录described in the documentation

  

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