事务加锁: begin tran select * into test1 from test with(ROWLOCK) where testcode>5 delete from test with(ROWLOCK) where testcode>5commit tran
begin tran select * into test1 from test with(ROWLOCK) where testcode>5 delete from test with(ROWLOCK) where testcode>5 if @@error <> 0 rollback tran else commit tran
begin tran
select * into test1 from test with(ROWLOCK) where testcode>5
delete from test with(ROWLOCK) where testcode>5commit tran
select * into test1 from test with(ROWLOCK) where testcode>5
delete from test with(ROWLOCK) where testcode>5
if @@error <> 0
rollback tran
else
commit tran