In the end of my function, I have the statement:
RETURN @Result
What I want to do is something like this:
IF (@Result = '')
BEGIN
@Result = 'Unknown'
END
RETURN @Result
The above does not work though.
In the end of my function, I have the statement:
RETURN @Result
What I want to do is something like this:
IF (@Result = '')
BEGIN
@Result = 'Unknown'
END
RETURN @Result
The above does not work though.
IF (@Result = '')
BEGIN
SELECT @Result = 'Unknown'
END
RETURN @Result
Notice that the way you do assignment in T-SQL is the SELECT
statement. You can also use the SET
statement although that is discouraged.
change this line
@Result = 'Unknown'
to
set @Result = 'Unknown'
I think you need to check if @result is NULL, because NULL is not the same as ''
IF (ISNULL(@Result, '') = '')
BEGIN
SET @Result = 'Unknown'
END
RETURN @Result