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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Distributed Transaction
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ask SQLTeam Question

0 Posts

Posted - 03/17/2006 :  08:28:24  Show Profile  Visit AskSQLTeam's Homepage
Kammer writes "I am using two DBs (myDB1 and myDB2) in two SQL 2000 Servers (mySQLServer1 and mySQLServer2) respectively, but in on of my application process I want to insert into a table called myTable1 in myDB1 and I also want to update the corresponding data in a table called myTable2 in myDB2. But the problem is I have to complete the whole process as a transaction. If anything go wrong during the process, all the insert and update should be rollbacked."


United Kingdom
12543 Posts

Posted - 03/17/2006 :  10:02:17  Show Profile  Visit nr's Homepage
Call an sp

create proc xxxx
@val1 varchar(12) ,
@val2 varchar(12)

begin tran
insert tbl1 (val1) select @val1
if @@error <> 0
raiserror('failed', 16, -1)
rollback tran
update db2..tbl2 set val1 = @val1 where val2 = @val2
if @@error <> 0
raiserror('failed', 16, -1)
rollback tran
commit tran

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
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000