Properties

Owner: HumanResources 
Schema bound:  
Encrypted:  
Creation Date: 04/26/2006 
Modification Date: 04/26/2006 
Description: Returns employee name, title, and current department. 

Columns

Name Data Type Length NULL IsGUID Description
  EmployeeID  int       
  Title  nvarchar       
  FirstName  Name  100       
  MiddleName  Name  100       
  LastName  Name  100       
  Suffix  nvarchar  10       
  JobTitle  nvarchar  50       
  Department  Name  100       
  GroupName  Name  100       
  StartDate  datetime       
Total: 10 column(s)

Objects that [HumanResources].[vEmployeeDepartment] depends on

Object Name Owner Object Type Dep Level
  Flag  dbo  User Defined type 
  Name  dbo  User Defined type 
  NameStyle  dbo  User Defined type 
  Phone  dbo  User Defined type 
  Contact  Person  Table 
  Department  HumanResources  Table 
  Shift  HumanResources  Table 
  Employee  HumanResources  Table 
  EmployeeDepartmentHistory  HumanResources  Table 
Total: 9 objects

SQL


CREATE VIEW [HumanResources].[vEmployeeDepartment]
AS
SELECT
    e.[EmployeeID]
    ,c.[Title]
    ,c.[FirstName]
    ,c.[MiddleName]
    ,c.[LastName]
    ,c.[Suffix]
    ,e.[Title] AS [JobTitle]
    ,d.[Name] AS [Department]
    ,d.[GroupName]
    ,edh.[StartDate]
FROM [HumanResources].[Employee] e
    INNER JOIN [Person].[Contact] c
    ON c.[ContactID] = e.[ContactID]
    INNER JOIN [HumanResources].[EmployeeDepartmentHistory] edh
    ON e.[EmployeeID] = edh.[EmployeeID]
    INNER JOIN [HumanResources].[Department] d
    ON edh.[DepartmentID] = d.[DepartmentID]
WHERE GETDATE() BETWEEN edh.[StartDate] AND ISNULL(edh.[EndDate], GETDATE());

See Also

List of views