I am working on an assignment and found some trouble. Here is the assignment:
This assignment will use the northwind database and the Employees table.
This will be a table user defined function.
Create a user defined function named Employee_Name. Pass an Employee Id as a parameter.
Return the First Name, Last Name, and Phone Number of the employee whose ID matches the id passed to the user defined function.
Create a query that uses the function and returns information for the employee with an id of 5.
Here is my solution so far:
CREATE FUNCTION dbo.Employee_Name(@employId int)
RETURNS TABLE
AS
RETURN(
SELECT FirstName,LastName,HomePhone
FROM dbo.Employees
WHERE EmployeeID = @employId
GROUP BY EmployeeID
)
SELECT * FROM dbo.Employee_Name(5);
GO
Here is the error I'm receiving:
Msg 156, Level 15, State 1, Procedure Employee_Name, Line 11
Incorrect syntax near the keyword 'SELECT'.