Chapter 10A – Managing Databases with SQL Server 2017
❖ ANSWERS TO MORGAN IMPORTING PROJECT QUESTIONS
If you have not completed the discussion of Morgan Importing database at the end of
Chapter 7 on pages 390–395, work through the Chapter 7 Morgan Importing Project
Questions now. Use the MI database that you created in the Chapter 7 MI Project
Questions as the basis for your answers to the following questions:
Using the MI database, create an SQL script named MI-Create-Views-and-Functions .sql
to answer questions A through D.
NOTE: We are using and extending the MI_CH07 database we created and used in Chapter 7.
A. Create and test a user-defined function named LastNameFirst that combines two
parameters named FirstName and LastName into a concatenated name field formatted
LastName, FirstName (including the comma and space).
CREATE OR ALTER FUNCTION dbo.LastNameFirst
— These are the input parameters
/****** Test Function ***********************************************************/
SELECT dbo.LastNameFirst(FirstName, LastName) AS EmployeeName,
OfficePhone, EmailAddress
FROM EMPLOYEE
ORDER BY EmployeeID;