| Owner: | Sales |
| Schema bound: | |
| Encrypted: | |
| Creation Date: | 04/26/2006 |
| Modification Date: | 04/26/2006 |
| Description: | Individual customers (names and addresses) that purchase Adventure Works Cycles products online. |
| Name | Data Type | Length | NULL | IsGUID | Description | |
| CustomerID | int | 4 | ||||
| Title | nvarchar | 8 | ||||
| FirstName | Name | 100 | ||||
| MiddleName | Name | 100 | ||||
| LastName | Name | 100 | ||||
| Suffix | nvarchar | 10 | ||||
| Phone | Phone | 50 | ||||
| EmailAddress | nvarchar | 50 | ||||
| EmailPromotion | int | 4 | ||||
| AddressType | Name | 100 | ||||
| AddressLine1 | nvarchar | 60 | ||||
| AddressLine2 | nvarchar | 60 | ||||
| City | nvarchar | 30 | ||||
| StateProvinceName | Name | 100 | ||||
| PostalCode | nvarchar | 15 | ||||
| CountryRegionName | Name | 100 | ||||
| Demographics | xml | -1 |
Objects that [Sales].[vIndividualCustomer] depends on
| Object Name | Owner | Object Type | Dep Level | |
| Flag | dbo | User Defined type | 1 | |
| Name | dbo | User Defined type | 1 | |
| NameStyle | dbo | User Defined type | 1 | |
| Phone | dbo | User Defined type | 1 | |
| ufnLeadingZeros | dbo | Function | 2 | |
| AddressType | Person | Table | 2 | |
| Contact | Person | Table | 2 | |
| CountryRegion | Person | Table | 2 | |
| SalesTerritory | Sales | Table | 2 | |
| Customer | Sales | Table | 3 | |
| StateProvince | Person | Table | 3 | |
| Address | Person | Table | 4 | |
| Individual | Sales | Table | 4 | |
| CustomerAddress | Sales | Table | 5 |
CREATE VIEW [Sales].[vIndividualCustomer]
AS
SELECT
i.[CustomerID]
,c.[Title]
,c.[FirstName]
,c.[MiddleName]
,c.[LastName]
,c.[Suffix]
,c.[Phone]
,c.[EmailAddress]
,c.[EmailPromotion]
,at.[Name] AS [AddressType]
,a.[AddressLine1]
,a.[AddressLine2]
,a.[City]
,[StateProvinceName] = sp.[Name]
,a.[PostalCode]
,[CountryRegionName] = cr.[Name]
,i.[Demographics]
FROM [Sales].[Individual] i
INNER JOIN [Person].[Contact] c
ON c.[ContactID] = i.[ContactID]
INNER JOIN [Sales].[CustomerAddress] ca
ON ca.[CustomerID] = i.[CustomerID]
INNER JOIN [Person].[Address] a
ON a.[AddressID] = ca.[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 ca.[AddressTypeID] = at.[AddressTypeID]
WHERE i.[CustomerID] IN (SELECT [Sales].[Customer].[CustomerID]
FROM [Sales].[Customer] WHERE UPPER([Sales].[Customer].[CustomerType]) = 'I');
See Also
List of views