问题
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