Explanatory Question
Create an inline table valued function
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.
CREATE FUNCTION fn_EmployeesByGender(@Gender nvarchar(10)) RETURNS TABLE AS RETURN (Select Id, Name, DateOfBirth, Gender, DepartmentId from Employees where Gender = @Gender)
Select * from fn_EmployeesByGender('Male')
Select Name, Gender, DepartmentName from fn_EmployeesByGender('Male') E Join tblDepartment D on D.Id = E.DepartmentId
CREATE TABLE Employees ( Id INT IDENTITY(1, 1) PRIMARY KEY NOT NULL, Name NVARCHAR(50), DateOfBirth DATETIME, Gender NVARCHAR(50), DepartmentId INT ); INSERT INTO Employees VALUES ('Rambo', '1980-12-30', 'Male', 1) INSERT INTO Employees VALUES ('Roma', '1982-09-01 12:02:36.260', 'Female', 2) INSERT INTO Employees VALUES ('Inza', '1985-08-22 12:03:30.370', 'Male', 1) INSERT INTO Employees VALUES ('Sara', '1979-11-29 12:59:30.670', 'Female', 3) INSERT INTO Employees VALUES ('Azam', '1978-11-29 12:59:30.670', 'Male', 1) Select * from Employees
First read the answer fully, then try to explain it in your own words. After that, open a few related questions and compare the concepts. This method helps you remember the topic for a longer time and improves exam preparation.