create procedure transfer
@cash int,
@accountOld varchar(10),
@accountNew varchar(10)
as
set nocount on -->加上这句试试
begin
if(@accountNew in (select accountid from userCount))
begin
if((select balance from userCount where accountid=@accountOld)>@cash)
begin
update userCount set balance=balance-@cash where accountid=@accountOld
update userCount set balance=balance+@cash where accountid=@accountNew
print'转账成功'
end
else
begin
print'账户余额不足,无法进行交易'
end
end
else
begin
print'不存在该账户,无法进行转账'
end
end
set nocount off -->这里也加一句
go
exec transfer 100,'426362175','111'
@cash int,
@accountOld varchar(10),
@accountNew varchar(10)
as
set nocount on -->加上这句试试
begin
if(@accountNew in (select accountid from userCount))
begin
if((select balance from userCount where accountid=@accountOld)>@cash)
begin
update userCount set balance=balance-@cash where accountid=@accountOld
update userCount set balance=balance+@cash where accountid=@accountNew
print'转账成功'
end
else
begin
print'账户余额不足,无法进行交易'
end
end
else
begin
print'不存在该账户,无法进行转账'
end
end
set nocount off -->这里也加一句
go
exec transfer 100,'426362175','111'
@cash int,
@accountOld varchar(10),
@accountNew varchar(10)
as
begin
--if(@accountNew in (select accountid from userCount))
--modify********************************************************
if exists(select 1 from userCount where accountid=@accountNew )
--*******************************************************************
begin
if((select balance from userCount where accountid=@accountOld)>@cash)
begin
update userCount set balance=balance-@cash where accountid=@accountOld
update userCount set balance=balance+@cash where accountid=@accountNew
print'转账成功'
end
else
begin
print'账户余额不足,无法进行交易'
end
end
else
begin
print'不存在该账户,无法进行转账'
end
end