程式1:commit in Transact-SQL
BEGIN TRAN AA
DELETE FROM Students WHERE sid = 'S001';
COMMIT TRAN AA 【確定執行,無法再rollback】
如果交易失敗,復原是使用ROLLBACK TRAN指令結束,如下所示:
程式2:rollback in Transact-SQL
BEGIN TRAN
DELETE FROM Students WHERE sid = 'S001';
ROLLBACK TRAN AA 【回覆上次動作】
-------------範例如下------------
SELECT *
FROM Orders
WHERE (OrderID = '10248')
begin tran aa
update orders
set ShipAddress=
'KARAAAES' WHERE (OrderID = '10248')
COMMIT TRAN aa
rollback tran aa
沒有留言:
張貼留言