Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Lookup Question Expand / Collapse
Author
Message
Posted Saturday, June 27, 2009 11:09 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, October 9, 2014 7:20 AM
Points: 41, Visits: 212
I'm using the Lookup Transformation to obtain a PhoneGuid from a Phone table. However this phone table also has another column called PhoneTypeGuid which is from another table that has different Guid's for the different phone types;
home, work, fax, mobile

From my source system I have the phone number and I know whether it's a home or work, So I've got 2 lookup's, one to return a PhoneGuid for home phone being converted and one for the work phone. What I need to do though is join this PhoneType table in the lookup so if the phone number exists as a home and work number the correct Guid is returned and it doesn't error out since it would return 2 rows.

So my lookup needs to do the following basically;

SELECT PhoneRawUnencrypted.PhoneUid
FROM ListPhoneType INNER JOIN
PhoneRawUnencrypted ON ListPhoneType.PhoneTypeUid = PhoneRawUnencrypted.PhoneTypeUid
WHERE (ListPhoneType.Name = 'home')
AND PhoneRawUnencrypted.Number = ?

Where the number is the phone number from the source system. I can only select one table from the drop down and if I put this SQL in it doesn't like it.

Any ideas how to accomplish this?

Joe
Post #743143
Posted Saturday, June 27, 2009 12:15 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, October 9, 2014 7:20 AM
Points: 41, Visits: 212
I figured out how to do this. But now all my data is going to the error output.
I'm only doing 10 rows as a test and I looked at my data from the source
For example the one home phone is
999-8177

And I did the following in Sql Server
SELECT PhoneRawUnencrypted.PhoneUid, PhoneRawUnencrypted.PhoneNumber
FROM ListPhoneType INNER JOIN
PhoneRawUnencrypted ON ListPhoneType.PhoneTypeUid = PhoneRawUnencrypted.PhoneTypeUid
WHERE (ListPhoneType.Name = 'home')
AND PhoneRawUnencrypted.PhoneNumber = '999-8177'

It returns the following
B79ED43A-D135-4C5A-8B11-64B4A2315762 999-8177
So the data exist.
Why is it going to my error output?

Joe
Post #743155
Posted Sunday, June 28, 2009 6:45 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:21 AM
Points: 10,268, Visits: 13,247
Is there any padding on either end of the lookup? Try doing a trim on your source data and then trimming your lookup column as well. Unless you go into the advanced settings of the lookup it is doing the comparison in .NET not SQL so trailing spaces/blanks will have an affect.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #743261
Posted Sunday, June 28, 2009 7:40 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, October 9, 2014 7:20 AM
Points: 41, Visits: 212
I changed the cache from FULL to partial and that resolved it.

Can anyone explain this?
Post #743269
Posted Sunday, June 28, 2009 11:00 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:21 AM
Points: 10,268, Visits: 13,247
This relates to my previous post. By not doing a full cache, the comparison is actually being done by SQL Server. I'm not sure exactly what SSIS does in partial cache, but my guess is if a match is not found in memory then the query is sent to SQL Server and is done there. Basically you are making a call to the SQL Server for each row in your source. I'd really suggest trying trimming the data at the source and in the lookup as I think this will allow you to use the full cache and reduce the round-trips to the SQL Server.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #743288
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse