Views [Sales].[vStoreWithAddresses]
Stores (including store addresses) 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
AddressType[dbo].[Name]100
AddressLine1nvarchar(60)120
AddressLine2nvarchar(60)120
Citynvarchar(30)60
StateProvinceName[dbo].[Name]100
PostalCodenvarchar(15)30
CountryRegionName[dbo].[Name]100

CREATE VIEW [Sales].[vStoreWithAddresses] AS
SELECT
   s.[BusinessEntityID]
   ,s.[Name]
   ,at.[Name] AS [AddressType]
   ,a.[AddressLine1]
   ,a.[AddressLine2]
   ,a.[City]
   ,sp.[Name] AS [StateProvinceName]
   ,a.[PostalCode]
   ,cr.[Name] AS [CountryRegionName]
FROM [Sales].[Store] s
   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]
   INNER JOIN [Person].[AddressType] at
   ON at.[AddressTypeID] = bea.[AddressTypeID];
GO
EXEC sp_addextendedproperty N'MS_Description', N'Stores (including store addresses) that sell Adventure Works Cycles products to consumers.', 'SCHEMA', N'Sales', 'VIEW', N'vStoreWithAddresses', NULL, NULL
GO