I just started writing functions and began with something very basic, which is pulling just a region LIKE something (probably not useful but just trying to get the idea).
When I go to execute the function, however, the results I'm getting are giving me EVERY region even though I think I'm specifying in the subquery LIKE...and then try re-iterating in the exec statement.
Please advise on what I am missing; thanks!
CREATE FUNCTION Fn_GETMAXREGION(@REGION VARCHAR(20))
RETURNS @temp table
(REGION VARCHAR(20)) AS
INSERT INTO @temp
SELECT DISTINCT REGION
WHERE REGION IN
WHERE @REGION LIKE '1%'
SELECT * FROM Fn_GETMAXREGION ('1%')