Sales.vStoreWithContacts
Documentation | AdventureWorks |
Schema | Sales |
Name | vStoreWithContacts |
Module | Sales |
Stores (including store contacts) that sell Adventure Works Cycles products to consumers.
Columns
Key | Name | Data type | Null | Attributes | References | Description | ||
---|---|---|---|---|---|---|---|---|
1 | BusinessEntityID | int | ||||||
2 | Name | nvarchar(50) | ||||||
3 | ContactType | nvarchar(50) | ||||||
4 | Title | nvarchar(8) | ||||||
5 | FirstName | nvarchar(50) | ||||||
6 | MiddleName | nvarchar(50) | ||||||
7 | LastName | nvarchar(50) | ||||||
8 | Suffix | nvarchar(10) | ||||||
9 | PhoneNumber | nvarchar(25) | ||||||
10 | PhoneNumberType | nvarchar(50) | ||||||
11 | EmailAddress | nvarchar(50) | ||||||
12 | EmailPromotion | int |
Uses
Name |
---|
Sales.vStoreWithContacts
|
Script
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]; |
Exported: 2019-02-04 23:13, Last imported: 2018-03-07 11:56