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

旧城冷巷雨未停 提交于 2019-12-11 18:30:00

问题


With Options > Query Execution > ANSI > SET IMPLICIT_TRANSACTIONS, each batch is not committed automatically.

Even so, I have to run begin transaction in batch explicitly, i.e. 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?


回答1:


I think the IMPLICIT_TRANSACTIONS setting works the way that you are hoping it does. Unless i'm understanding your question incorrectly.

Have you looked at the MSDN?

SET IMPLICIT_TRANSACTIONS to Checked in 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? And if you try and close the window, you will be prompted that there are uncommitted transactions.



来源:https://stackoverflow.com/questions/13295376/how-to-set-begin-transaction-automatically-in-ssms-sql-server-management-studio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!