Views [Sales].[vStoreWithContacts]
Stores (including store contacts) that sell Adventure Works Cycles products to consumers.
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
Name[dbo].[Name]100
ContactType[dbo].[Name]100
Titlenvarchar(8)16
FirstName[dbo].[Name]100
MiddleName[dbo].[Name]100
LastName[dbo].[Name]100
Suffixnvarchar(10)20
PhoneNumber[dbo].[Phone]50
PhoneNumberType[dbo].[Name]100
EmailAddressnvarchar(50)100
EmailPromotionint4

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];
GO
EXEC sp_addextendedproperty N'MS_Description', N'Stores (including store contacts) that sell Adventure Works Cycles products to consumers.', 'SCHEMA', N'Sales', 'VIEW', N'vStoreWithContacts', NULL, NULL
GO