if @nerror=2627
rollback transaction
raiserror('用户名以存在',16,10)
end
commit transaction
有错误就回滚 没错误提交 但是你这里 有错误后 回滚了操作 之后又会继续执行commit
所以你应该改为
if @nerror=2627
rollback transaction
raiserror('用户名以存在',16,10)
end
else
commit transaction
我也没仔细看 应该是这里错误了吧!