Northwind Database (Document! X Sample)
Sales.vStoreWithContacts View
AdventureWorks Database > Sales Schema : Sales.vStoreWithContacts View
Description
Stores (including store contacts) that sell Adventure Works Cycles products to consumers.
Properties
Creation Date27/10/2017 14:33
Is Schema Bound
Encrypted
Ansi Nulls
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
  Integer4   
  dbo.Name50   
  dbo.Name50   
  VarWChar8  
  dbo.Name50   
  dbo.Name50  
  dbo.Name50   
  VarWChar10  
  dbo.Phone25  
  dbo.Name50  
  VarWChar50  
  Integer4   
Objects that Sales.vStoreWithContacts depends on
 Database ObjectObject TypeDescriptionDep Level
Person.BusinessEntity tablePerson.BusinessEntityTableSource of the ID that connects vendors, customers, and employees with address and contact information.2
Person.BusinessEntityContact tablePerson.BusinessEntityContactTableCross-reference table mapping stores, vendors, and employees to people1
Person.ContactType tablePerson.ContactTypeTableLookup table containing the types of business entity contacts.1
Person.CountryRegion tablePerson.CountryRegionTableLookup table containing the ISO standard codes for countries and regions.4
Person.EmailAddress tablePerson.EmailAddressTableWhere to send a person email.1
HumanResources.Employee tableHumanResources.EmployeeTableEmployee information such as salary, department, and title.3
dbo.Flag datatypedbo.FlagUser Defined Data Type 4
dbo.Name datatypedbo.NameUser Defined Data Type 2
dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 2
Person.Person tablePerson.PersonTableHuman beings involved with AdventureWorks: employees, customer contacts, and vendor contacts.1
Person.PersonPhone tablePerson.PersonPhoneTableTelephone number and type of a person.1
dbo.Phone datatypedbo.PhoneUser Defined Data Type 2
Person.PhoneNumberType tablePerson.PhoneNumberTypeTableType of phone number of a person.1
Sales.SalesPerson tableSales.SalesPersonTableSales representative current information.2
Sales.SalesTerritory tableSales.SalesTerritoryTableSales territory lookup table.3
Sales.Store tableSales.StoreTableCustomers (resellers) of Adventure Works products.1
View Definition
CREATE VIEW [Sales].[vStoreWithContacts] AS 

SELECT 
    s.[BusinessEntityID] 
    ,s.[Name] 
    ,ct.[Name] AS [ContactType] 
    ,p.[Title] 
    ,p.[FirstName] 
    ,p.[MiddleName] 
    ,p.[LastName] 
    ,p.[Suffix] 
    ,pp.[PhoneNumber] 
    ,pnt.[Name] AS [PhoneNumberType]
    ,ea.[EmailAddress] 
    ,p.[EmailPromotion] 
FROM [Sales].[Store] s
    INNER JOIN [Person].[BusinessEntityContact] bec 
    ON bec.[BusinessEntityID] = s.[BusinessEntityID]
    INNER JOIN [Person].[ContactType] ct
    ON ct.[ContactTypeID] = bec.[ContactTypeID]
    INNER JOIN [Person].[Person] p
    ON p.[BusinessEntityID] = bec.[PersonID]
    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];
See Also

Related Objects

Sales Schema
AdventureWorks Database