if object_id('fnIIF') is not null drop function fnIIF GO create function fnIIF(@i int) returns int as begin return case when @i <= 0 then 0 else @i end end GOselect dbo.fnIIF(0),dbo.fnIIF(-9),dbo.fnIIF(9)drop function fnIIF
case when col < 0 then 0 else col end case when col=<0 then 0 else col end 这两个没区别
select case when col<=0 then 0 else col end
drop function fnIIF
GO
create function fnIIF(@i int)
returns int
as
begin
return case when @i <= 0 then 0 else @i end
end
GOselect dbo.fnIIF(0),dbo.fnIIF(-9),dbo.fnIIF(9)drop function fnIIF
case when col=<0 then 0 else col end
这两个没区别