开发者

Error: There are uncommitted transactions

开发者 https://www.devze.com 2023-02-17 23:09 出处:网络
I open a new window in SSMS and run this: SET ANSI_DEFAULTS ON GO CREATE PROCEDURE [dbo].[zzz_test2] ( @aint

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

0

精彩评论

暂无评论...
验证码 换一张
取 消