By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,856 Members | 2,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,856 IT Pros & Developers. It's quick & easy.

Transaction across 2 databases?

P: n/a
Is it possible to wrap a transaction across 2 database? For example:

BEGIN TRANSACTION

.... alter something in Database_1

.... alter something in Database_2

COMMIT TRANSACTION
or if there is any error:
ROLLBACK TRANSACTION
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Robin Tucker (id*************************@reallyidont.com) writes:
Is it possible to wrap a transaction across 2 database? For example:

BEGIN TRANSACTION

.... alter something in Database_1

.... alter something in Database_2

COMMIT TRANSACTION
or if there is any error:
ROLLBACK TRANSACTION


Yes, just go ahead.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2

P: n/a
I don't know why but I was under the impression you couldn't do this! (Under
the impression for the past year while I've been developing my software
while looking nervously at the size of the crack between one database and
the other, through which partially completed operations might fall!). Well,
good news indeed.

"Erland Sommarskog" <es****@sommarskog.se> wrote in message
news:Xn*********************@127.0.0.1...
Robin Tucker (id*************************@reallyidont.com) writes:
Is it possible to wrap a transaction across 2 database? For example:

BEGIN TRANSACTION

.... alter something in Database_1

.... alter something in Database_2

COMMIT TRANSACTION
or if there is any error:
ROLLBACK TRANSACTION


Yes, just go ahead.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Jul 23 '05 #3

P: n/a
Robin,

Transaction is a server wide concept rather than database wise. It is
perfectly valid to have cross database transaction. As a matter of fact,
one can even condutc cross server/apps distributed transaction using MSDTC
(BEGIN DISTRIBUTED TRAN).

--
Gang He
Software Design Engineer
Microsoft SQL Server Storage Engine

This posting is provided "AS IS" with no warranties, and confers no rights.
"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cs*******************@news.demon.co.uk...
Is it possible to wrap a transaction across 2 database? For example:

BEGIN TRANSACTION

.... alter something in Database_1

.... alter something in Database_2

COMMIT TRANSACTION
or if there is any error:
ROLLBACK TRANSACTION

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.