日期:2014-05-18 浏览次数:20533 次
declare @a int declare @b int set @a=-3 select @b=case when @a<0 then 0 else @a end select @b as value /* value 0 */ --你这样不行吗??
------解决方案--------------------
if object_id('[lsxf1988_Table]') is not null drop table [lsxf1988_Table] create table [lsxf1988_Table]([AVAILABLE_STOCK] int) insert [lsxf1988_Table] select -1 union all select 9 union all select 8 declare @AVAILABLE_STOCK int set @AVAILABLE_STOCK=( select top 1 case when AVAILABLE_STOCK<0 then 0 else AVAILABLE_STOCK end from [lsxf1988_Table]) select @AVAILABLE_STOCK as [库存] /* 库存 ----------- 0 */