Developers moving from Oracle to SQL Server often face issues with commit transactions. Because Oracle doesn't do AUTO COMMIT but SQL Server does and here developer faces the issues. Sometimes during testing we delete rows which we shouldn't be and can't ROLLBACK as these transactions in SQL Server are auto committed by default.
So the question is can we set this off ? Yes, we can and here is how you can do that.
There are two ways to achieve this.
You can disable AUTO COMMIT at database level as shown below.
Option 1
- Open SQL Server Management Studio
- Right Click on Server and Select Properties
- You will now be in Server Properties
- Go to Connections page and check the options as shown below.
Option 2
- Connect to Database Instance where you want to set Auto Commit off.
- Go to SQLQuery window
- Execute below command
SET IMPLICIT_TRANSACTIONS ON;
Once this is executed , you can use ROLLBACK to undo the changes or COMMIT to save the changes.