I have created a function that responds to the following code:
-- Pasando un numero de departamento, obtener los empleados de este y su id.
CREATE FUNCTION F_Emp_NumEmp
(@NumDe NUMERIC(3))
RETURNS TABLE
AS
RETURN (
SELECT
td.NumDe, NumEm, Nombre
FROM
TDepto td INNER JOIN Temple tem ON (td.NumDe = tem.NumDe)
WHERE
td.NumDe = @NumDe
);
-- Invocacion
SELECT
*
FROM
dbo.F_Emp_NumEmp(121)
The problem I have is that I do not find any method to perform flow control within it, and I have not found any reference, I mean, what I'm trying to do is that when invoking this function, the introduced parameter does not return any value , show a personalized message, as well as if the same function is not sent any parameter, show another different message.