Views [Sales].[vSalesPerson]
Sales representiatives (names and addresses) and their sales-related information.
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
JobTitlenvarchar(50)100
PhoneNumber[dbo].[Phone]50
PhoneNumberType[dbo].[Name]100
EmailAddressnvarchar(50)100
EmailPromotionint4
AddressLine1nvarchar(60)120
AddressLine2nvarchar(60)120
Citynvarchar(30)60
StateProvinceName[dbo].[Name]100
PostalCodenvarchar(15)30
CountryRegionName[dbo].[Name]100
TerritoryName[dbo].[Name]100
TerritoryGroupnvarchar(50)100
SalesQuotamoney8
SalesYTDmoney8
SalesLastYearmoney8

CREATE VIEW [Sales].[vSalesPerson]
AS
SELECT
   s.[BusinessEntityID]
   ,p.[Title]
   ,p.[FirstName]
   ,p.[MiddleName]
   ,p.[LastName]
   ,p.[Suffix]
   ,e.[JobTitle]
   ,pp.[PhoneNumber]
   ,pnt.[Name] AS [PhoneNumberType]
   ,ea.[EmailAddress]
   ,p.[EmailPromotion]
   ,a.[AddressLine1]
   ,a.[AddressLine2]
   ,a.[City]
   ,[StateProvinceName] = sp.[Name]
   ,a.[PostalCode]
   ,[CountryRegionName] = cr.[Name]
   ,[TerritoryName] = st.[Name]
   ,[TerritoryGroup] = st.[Group]
   ,s.[SalesQuota]
   ,s.[SalesYTD]
   ,s.[SalesLastYear]
FROM [Sales].[SalesPerson] s
   INNER JOIN [HumanResources].[Employee] e
   ON e.[BusinessEntityID] = s.[BusinessEntityID]
   INNER JOIN [Person].[Person] p
   ON p.[BusinessEntityID] = s.[BusinessEntityID]
   INNER JOIN [Person].[BusinessEntityAddress] bea
   ON bea.[BusinessEntityID] = s.[BusinessEntityID]
   INNER JOIN [Person].[Address] a
   ON a.[AddressID] = bea.[AddressID]
   INNER JOIN [Person].[StateProvince] sp
   ON sp.[StateProvinceID] = a.[StateProvinceID]
   INNER JOIN [Person].[CountryRegion] cr
   ON cr.[CountryRegionCode] = sp.[CountryRegionCode]
   LEFT OUTER JOIN [Sales].[SalesTerritory] st
   ON st.[TerritoryID] = s.[TerritoryID]
   LEFT OUTER JOIN [Person].[EmailAddress] ea
   ON ea.[BusinessEntityID] = p.[BusinessEntityID]
   LEFT OUTER JOIN [Person].[PersonPhone] pp
   ON pp.[BusinessEntityID] = p.[BusinessEntityID]
   LEFT OUTER JOIN [Person].[PhoneNumberType] pnt
   ON pnt.[PhoneNumberTypeID] = pp.[PhoneNumberTypeID];
GO
EXEC sp_addextendedproperty N'MS_Description', N'Sales representiatives (names and addresses) and their sales-related information.', 'SCHEMA', N'Sales', 'VIEW', N'vSalesPerson', NULL, NULL
GO