What's wrong with this T-SQL? #2
Hint: Today's question is pretty easy if you understand which SQL Server data type are valid for which operations with user-defined functions. What you want to build is a scalar-value function named GetBooleanTextFromInt that returns a boolean text string based on an integer passed to it. So if you pass 0 (zero) to it, it returns the text 'False'. Any other integer value passed to it should return the text 'True'. For example:
SELECT GetBooleanTextFromInt(0) AS 'BooleanText'
returns a single field named BooleanText with the text value 'False' in it. while
SELECT GetBooleanTextFromInt(12) AS 'BooleanText'
returns a single field named BooleanText with the text value 'True' in it.
Here is the initial function, try to spot the problem(s):
CREATE FUNCTION GetBooleanTextFromInt (@num1 int)
RETURNS text
AS
BEGIN
IF @num1 = 0
BEGIN
RETURN 'False'
END
ELSE
RETURN 'True'
END