Views [HumanResources].[vEmployeeDepartmentHistory]
Returns employee name and current and previous departments.
PropertyValue
CollationSQL_Latin1_General_CP1_CI_AS
ANSI Nulls OnTrue
Quoted Identifier OnTrue
Created13:14:55 14 marca 2012
Last Modified13:14:55 14 marca 2012
NameData TypeMax Length (Bytes)
BusinessEntityIDint4
Titlenvarchar(8)16
FirstName[dbo].[Name]100
MiddleName[dbo].[Name]100
LastName[dbo].[Name]100
Suffixnvarchar(10)20
Shift[dbo].[Name]100
Department[dbo].[Name]100
GroupName[dbo].[Name]100
StartDatedate3
EndDatedate3

CREATE VIEW [HumanResources].[vEmployeeDepartmentHistory]
AS
SELECT
   e.[BusinessEntityID]
   ,p.[Title]
   ,p.[FirstName]
   ,p.[MiddleName]
   ,p.[LastName]
   ,p.[Suffix]
   ,s.[Name] AS [Shift]
   ,d.[Name] AS [Department]
   ,d.[GroupName]
   ,edh.[StartDate]
   ,edh.[EndDate]
FROM [HumanResources].[Employee] e
   INNER JOIN [Person].[Person] p
   ON p.[BusinessEntityID] = e.[BusinessEntityID]
   INNER JOIN [HumanResources].[EmployeeDepartmentHistory] edh
   ON e.[BusinessEntityID] = edh.[BusinessEntityID]
   INNER JOIN [HumanResources].[Department] d
   ON edh.[DepartmentID] = d.[DepartmentID]
   INNER JOIN [HumanResources].[Shift] s
   ON s.[ShiftID] = edh.[ShiftID];
GO
EXEC sp_addextendedproperty N'MS_Description', N'Returns employee name and current and previous departments.', 'SCHEMA', N'HumanResources', 'VIEW', N'vEmployeeDepartmentHistory', NULL, NULL
GO