I have an SQL function which returns a list of Teams.
I want to join an additional list to that list with a union, but only if first select returns more than one rows.
Something like:
CREATE FUNCTION Teams()
RETURNS TABLE
AS
RETURN
(
SELECT * FROM TABLE1
if @@rowcount>1
UNION
SELECT * FROM TABLE2
end if
)