user56250
user56250

Reputation:

SQL Server 2008 BACKUP with IMPLICIT_TRANSACTIONS ON

this isn't a question for a solution per se, I am trying to understand a very strange behaviour in Management Studio.

I totally understand that BACKUP and RESTORE database can't be executed under a transaction and what the implications of SET IMPLICIT_TRANSACTIONS ON are.

So I conducted an experiment:

My question is - why it allows to execute BACKUP right after connecting and fails after changing the database?

Upvotes: 0

Views: 1226

Answers (1)

gbn
gbn

Reputation: 432431

BACKUP can not be in a transaction

The BACKUP statement is not allowed in an explicit or implicit transaction.

When changing the database away from master, you are issuing one of the commands described in SET IMPLICIT_TRANSACTIONS ON (use SQL Profiler to see) and creating a transaction.

Based on experience (without actually checking!) it will be a SELECT for Intellisense or Object Explorer or to get some other MetaData. I'm also guessing that something like Intellisense isn't used for system databases (I switch the damn thing off and use 3rd party tools) so it doesn't happen initially

Subsequent errors happen because you're still in a transaction

Upvotes: 2

Related Questions