Re: how to roll back
From: Greg Linwood (g_linwoodQhotmail.com)
Date: 03/29/04
- Next message: TomT: "RE: Log Shipping over T1"
- Previous message: Baisong Wei[MSFT]: "RE: AWE SQL Performance Problem"
- In reply to: pk: "how to roll back"
- Next in thread: Andras Jakus: "Re: how to roll back"
- Reply: Andras Jakus: "Re: how to roll back"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 29 Mar 2004 13:32:17 +1000
Hi pk.
You can only use rollback within a transaction block. If you commit a
transaction, there's no way to roll it back later.
A quick demo of how to use rollback in tsql is:
declare @err int
declare @err = 0
set xact_abort off -- set off or on for auto rollback on any error
set transaction isolation level read committed -- sets isolation (locking)
level
begin transaction
update table1 set column1 = 'a' where columnpk = 123
set @err = @err + @@error
insert into table2 (column2, column3) values ('1', 123)
set @err = @err + @@error
if @@error != 0
rollback
else
commit
HTH
Regards,
Greg Linwood
SQL Server MVP
"pk" <pk@> wrote in message news:epHxmqTFEHA.3424@tk2msftngp13.phx.gbl...
> is this the only way to do a rollback in SQL2000 ?
>
> Use Query Analyzer, BEGIN TRAN ...... COMMIT TRAN, then ROLLBACK TRAN to
> undo the changes. And only applicable for UPDATE & DELETE queries within
the
> transaction.
>
> just want to understand more how to use rollback and how it works.
>
> tks
> pk
>
>
- Next message: TomT: "RE: Log Shipping over T1"
- Previous message: Baisong Wei[MSFT]: "RE: AWE SQL Performance Problem"
- In reply to: pk: "how to roll back"
- Next in thread: Andras Jakus: "Re: how to roll back"
- Reply: Andras Jakus: "Re: how to roll back"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|