sql里数据类型 varchar 转换为 int 时出错,请教下面的题那里错了,求救

2025-04-13 03:58:38
推荐回答(1个)
回答(1):

if @nerror=2627
rollback transaction
raiserror('用户名以存在',16,10)
end
commit transaction

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