How to Stop a query from Auto Committing in Microsoft SQL Server Management Studio.
By default Microsoft SQL Server Management Studio Query (Query Analyzer) auto commits leaving no option to rollback. I had been very use to this and preferred it this way, however, recently I had been working in an environment with different tools where explicit commit was the preferred way and so now I want the flexibility of both in SQL Server as well.
One option is to turn on implicit transactions at the beginning of your query using “set implicit_transactions on”. When this is on, you will still see all of the updated or inserted row counts when executing your query, but you will have the option to rollback or commit.
Another way is to turn on implicit transactions by default within SQL Server Management Studio.
- Tools –> Options
- Expand Query Execution –> SQL Server
- Select ANSI
- Either Check SET IMPLICIT_TRANSACTIONS or SET ANSI_DEFAULTS
JUST BECAREFUL. Don’t leave a transaction open because it may end up blocking other users. Always make sure to commit or rollback.
Tags: SQL ServerYou can comment below, or link to this permanent URL from your own site.