declare @tranname varchar(32)
select @tranname= 'mytran '
begin tran @tranname
delete from products where productid=1
save tran save_point
delete from details where productid=1
if @@error=0 then
begin
rollback tran save_point
commit tran mytran
end
else
commit tran mytran
go
------解决方案--------------------
save tran save_point--设置事务保存点
rollback tran save_point ---回滚到事务保存点