insert record in two database
-
hello all, My application in windows C#. i have two database in sql server 2005. i want to insert record in both database but the major concern is that if any one failed its transaction then it should rollback both trasaction in both databases. please guide me for this.....
Amit Agarwal
-
hello all, My application in windows C#. i have two database in sql server 2005. i want to insert record in both database but the major concern is that if any one failed its transaction then it should rollback both trasaction in both databases. please guide me for this.....
Amit Agarwal
Amit Agarrwal wrote:
want to insert record in both database but the major concern is that if any one failed its transaction then it should rollback both trasaction in both databases
This is called distributed transaction where you have a special coordinator which takes care of the transactions. The transactions themselves are ended using two-phase commit. You could start here: http://msdn.microsoft.com/en-us/library/ms191440.aspx[^] A slightly different variation is using Linked Servers.
Amit Agarrwal wrote:
i have two database in sql server 2005
Just wondering what that actually means. If you have two different SQL Server instances, then you need to distribute the transaction (one way or another), but if you have two different databases inside a single SQL Server instance, you can use normal transactions.
The need to optimize rises from a bad design.My articles[^]