简体   繁体   English

如何在SSMS(SQL Server Management Studio)中自动设置BEGIN_TRANSACTION?

[英]How to set BEGIN_TRANSACTION automatically in SSMS (SQL Server Management Studio)?

With Options > Query Execution > ANSI > SET IMPLICIT_TRANSACTIONS , each batch is not committed automatically. 使用Options > Query Execution > ANSI > SET IMPLICIT_TRANSACTIONS ,不会自动提交每个批次。

Even so, I have to run begin transaction in batch explicitly, ie if I just run update table_name set col_name = 'something' without the begin trans , the update is automatically committed, can I actually ask set up SSMS such that it will automatically create a transaction when I execute a update\\insert\\delete batch? 即使这样,我也必须显式地批量运行begin transaction ,即如果我只运行update table_name set col_name = 'something'而没有begin trans ,则更新将自动提交,我是否可以要求设置SSMS使其自动创建执行update\\insert\\delete批处理时进行交易?

I think the IMPLICIT_TRANSACTIONS setting works the way that you are hoping it does. 我认为IMPLICIT_TRANSACTIONS设置的工作方式与您希望的一样。 Unless i'm understanding your question incorrectly. 除非我不正确地理解您的问题。

Have you looked at the MSDN ? 您是否看过MSDN

SET IMPLICIT_TRANSACTIONS to Checked in SSMS 将SET IMPLICIT_TRANSACTIONS设置为已在SSMS中检查

Then open a new query window 然后打开一个新的查询窗口

USE TempDb
CREATE TABLE tmp (f INT)
INSERT tmp VALUES (1)
print @@trancount

is 1. Isn't that what you're looking for? 是1.不是您要的内容吗? And if you try and close the window, you will be prompted that there are uncommitted transactions. 并且,如果尝试关闭窗口,系统将提示您有未提交的事务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 SQL Server Management Studio (SSMS) 中评论 SQL 查询 - How to comment SQL queries in SQL Server Management Studio (SSMS) 如何在SQL Server Management Studio(SSMS)中合并这些列 - How can I combine these columns in SQL Server Management Studio (SSMS) 如何在SQL Server Management Studio中将1设置为0…1关系 - How to set 1 to 0…1 relationship in SQL Server Management Studio 在 SQL Server Management Studio(SSMS) 中评论和取消评论 SQL 查询的快捷方式 - Shortcuts to comment and uncomment SQL queries in SQL Server Management Studio(SSMS) 从没有SQL Server Management Studio(SSMS)的MDF创建BAK - Create BAK from MDF without SQL Server Management Studio (SSMS) 禁用 SQL Server Management Studio (SSMS) 中的空白文本副本 - Disabling copy of blank text in SQL Server Management Studio (SSMS) 有没有办法在 SQL Server Management Studio (SSMS) 中分隔查询结果? - Is there a way to separate query results in SQL Server Management Studio (SSMS)? 在SSMS(SQL Server Management Studio)中,当列为只读时如何添加行? - In SSMS (Sql Server management Studio) how do I add a row to when a column is read only? 事务(进程ID)陷入僵局:SQL Server Management Studio - Transaction (Process ID) was deadlocked: Sql Server Management Studio SQL创建表在SQL Server Management Studio SSMS中不起作用 - SQL- Create table does not work in SQL Server Management Studio SSMS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM