In Microsoft SQL Server Management Studio I created a user defined function to calculate an employee's age based on the date of birth the user inputs as follows:
USE [Northwind];
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION udf_GetEmployeeAge_test2
(
@DateOfBirth datetime
)
RETURNS int
AS
BEGIN
DECLARE @Age int
SELECT @Age = DATEDIFF(DAY, @DateOfBirth, GETDATE())
RETURN @Age
END
I'm using the popular sample Northwind database, now the thing I can't seem to figure out is how and where do I include a select statement to return each employee name(FirstName),
surname(LastName),
date of birth(BirthDate)
and age and then also wrap the Select statement in a stored procedure(usp_EmployeeAges).
The info for these columns are in a table called dbo.Employees