Thursday, March 8, 2012

Chapter 1, Lesson 3, Pratice Exercise 2. Create a Data Flow Destination. Broken SQL Statement

I'm using the self paced training kit Exam 70-448: MCTS: Microsoft SQL Server 2008, Business Intelligence Development and Maintenance.

In my version of the book on page 52 the SQL command text for the Customer Source data flow sample is broken. The table join fields at the bottom of the statement don't exist.

Select convert(nvarchar(15), SC.
AccountNumber) as CustomerAlternateKey,
C.Title, C.FirstName, C.MiddleName,
C.LastName, C.Suffix, C.EmailAddress,
C.AddressLine1, C.AddressLine2,
D.BirthDate, D.MaritalStatus,
D.YearlyIncome, D.DateFirstPurchase,
D.Gender, D.TotalChildren,
D.NumberChildrenAtHome, D.Education,
D.Occupation, D.HomeOwnerFlag,
D.NumberCarsOwned
from Sales.vIndividualCustomer C
inner join Sales.Customer SC
on C.BusinessEntityID = SC.PersonID
inner join Sales.vPersonDemographics D
on C.BusinessEntityID =
D.BusinessEntityID

To fix this I created an new SQL statement in SSMS for the database in question and pasted in above sample.  I navigated to each table and inspected the fields.  I found that the BusinessEntityID and PersonID should all be changed to CustomerID as follows;

... from Sales.vIndividualCustomer C
inner join Sales.Customer SC
on C.CustomerID = SC.CustomerID
inner join Sales.vIndividualDemographics D
on C.CustomerID = D.CustomerID

A very simple fix.

No comments:

Post a Comment