|
Execute the following
script in Query Editor to create a view of all employee names:
USE AdventureWorks
IF object_id(N'Person.vEmployeeName', 'V') IS NOT NULL
DROP VIEW Person.vEmployeeName
GO
CREATE VIEW Person.vEmployeeName
AS
SELECT FirstName,
MiddleName,
LastName,
Name=LastName + ', ' + FirstName + COALESCE(' ' + MiddleName, '')
FROM Person.Contact c
JOIN HumanResources.Employee e
ON c.ContactID = e.ContactID
GO
SELECT * FROM Person.vEmployeeName
ORDER BY LastName, FirstName
GO
|