In SQL-Server am trying to create a function which turns negative values (int) into nulls/zero's. However the ways it is now all the numbers (also the positive ones) get turned into zero.
create FUNCTION planning.FN_test_return_zero_incaseof_negative_value (@value as int)
RETURNS int
BEGIN
if @value < 0 return 0
DECLARE @days as int
RETURN @days
END
GO
CodePudding user response:
create FUNCTION planning.FN_test_return_zero_incaseof_negative_value (@value as int)
RETURNS int
BEGIN
if @value < 0
return 0
return @value
END
GO