这里有个存储过程,为何报错,纠结求解
create proc check_username
@usercode char(16)
as
declare @retcode int , @retdesc char(80)
select @retcode=-999,@retdesc='用户名已存在'
if exists(select 1 from tbl_user where userid=@usercode)
begin
select @retcode=1,@retdesc='用户名已存在'
end
else
begin
select @retcode=0,@retdesc='用户名可以使用'
end
select @retcode as retcode,@retdesc as retdesc
[解决办法]
gocreate proc check_username@usercode char(16)asdeclare @retcode int , @retdesc char(80)select @retcode=-999,@retdesc='用户名已存在'if exists(select 1 from tbl where 部门=@usercode)beginselect @retcode=1,@retdesc='用户名已存在'endelsebeginselect @retcode=0,@retdesc='用户名可以使用'endselect @retcode as retcode,@retdesc as retdescexec check_username '1'/*retcode retdesc1 用户名已存在 */我的机器上测试没有报错