Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1498

Re: Some Doubt

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Some Doubt
Date 2013-05-29 22:57 +0200
Organization Erland Sommarskog
Message-ID <XnsA1CFE9953D132Yazorman@127.0.0.1> (permalink)
References <0a7b5498-c6dd-422e-a047-2af7466127b1@googlegroups.com>

Show all headers | View raw


SUBBU N (nsubbu1986@gmail.com) writes:
> Hi Experts,
> here onwards i will some qs regarding only for sqldba.can anyone clarify
> and suggest to me plz 
> 
> I have two databases, based on first db execution sucessful move to
> second, upon second db execution scucessful.. commit the
> transaction..if anything fail roll back transaction from both dbs
> 
> Example: DB1 and DB2
> DB1 has Dept and DB2 has Employee...
> now if dept and Employee data successfull then commit data in both DBs
> else rollback from both DBs..
> 

SET XACT_ABORT ON

BEGIN TRANSACTION

-- Updates here.

COMMIT TRANSACTION

It's important to set XACT_ABORT ON, since this ensure that the transaction
is rolled back in case of an error.

The pattern is the same if you update in one database or in two databases.


-- 
Erland Sommarskog, Stockholm, esquel@sommarskog.se

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Some Doubt SUBBU N <nsubbu1986@gmail.com> - 2013-05-29 00:12 -0700
  Re: Some Doubt Erland Sommarskog <esquel@sommarskog.se> - 2013-05-29 22:57 +0200
  Re: Some Doubt SUBBU N <nsubbu1986@gmail.com> - 2013-05-30 02:40 -0700

csiph-web