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.
SET @Result = 'Unknown'
@Justice: According to Microsoft - MSDN
SELECT @Result = 'Unknown' is generaly discouraged