Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Auto-Commit: how does it affect Begin/End Trans?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-01-25 : 08:22:46
Kevin writes "Probably a really easy question for you guys, but:

If Auto-commit is switched on, is it overridden by using Begin.....End Trans?
I want to test some scripts that perform updates, but don't want them commited to the tables, otherwise I can't retest later.
If the Begin...End Trans overrides the Auto-commit, then I can ROLLBACK to avoid saving the changes."

nr
SQLTeam MVY

12543 Posts

Posted - 2006-01-25 : 08:55:28
autocommit is the default mode.
It means that the implicit transaction created by a statement commits.
If you execute a begin tran then that will have to be commited explicitly as will a transaction created by setting implicit transactions on.

So the answer is yes - a rollback will rollback a trasaction started with a begin tran. It will not rollback a transaction created by an update statement outside an explicit transaction unless implicit transactions is on - in fact it will give an error.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -