Table Valued Function to return employye details of input department and location.

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 357
CREATE FUNCTION fn_EmpDetails
(@p_deptid INT,
@p_locid INT)
RETURNS @emps TABLE( empid int, lastname varchar(30))
BEGIN
INSERT INTO @emps
SELECT employee_id, last_name
FROM employees e
JOIN departments d ON (e.department_id = d.department_id
AND e.department_id = @p_deptid AND d.location_id = @p_locid)
RETURN
END
GO
SELECT * FROM fn_EmpDetails( 30, 1700)
GO

Comments or Responses

Login to post response