比如我现在想在一个存储过程中判断A表的B字段值如果 <0则退出这个存储过程不再往下执行,如果〉0则-1
------解决方案--------------------
create proc test (@name varchar(2))
as
if exists(select 1 from a where b <0 and [email protected])
print 'b小于0 '
else
print -1
------解决方案--------------------
select @a=b from a
if @a> 1
....
------解决方案--------------------
A表的B字段值如果 <0
create procedure protest
@where varchar(50)
as
declare @b int
select @b=b from a where [email protected]
case when @b <0
then
return
else
update a set b = b-1 where [email protected]
end
go