第一次写事务语句,求大虾们帮看看,这样写有没有问题?
谢谢
begin transaction t1
update table1 set ...
set @Isok = 1
IF @@ERROR <> 0
ROLLBACK
Else
COMMIT
谢谢
begin transaction t1
update table1 set ...
set @Isok = 1
IF @@ERROR <> 0
ROLLBACK
Else
COMMIT
begin transaction t1
update table1 set ...
set Isok = 1
IF @@ERROR <> 0
ROLLBACK transaction t1
Else
COMMIT transaction t1
begin transaction t1
update table1 set ...
set @Isok = 1 IF @@ERROR <> 0
ROLLBACK transaction t1
Else
COMMIT transaction t1
end transaction t1
那再虚心请教下,如果在ROLLBACK和COMMIT后面不加transaction t1语句
和
不加end transaction t1语句的话
如果出意外的话,会酿成什么后果呢?
谢谢
end transaction t1
加上后就提示出错"关键字 'transaction' 附近有语法错误。"
这是为什么呢?
求达人指教.
http://msdn.microsoft.com/zh-cn/vstudio/ms188929.aspx
UPDATE table1 ...
BEGIN TRAN M2 WITH MARK
UPDATE table2 ...
SELECT * from table1
COMMIT TRAN M2
UPDATE table3 ...
COMMIT TRAN T1