SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Lookup Question


Lookup Question

Author
Message
joepacelli
joepacelli
SSC-Addicted
SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)

Group: General Forum Members
Points: 466 Visits: 291
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
joepacelli
joepacelli
SSC-Addicted
SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)

Group: General Forum Members
Points: 466 Visits: 291
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
Jack Corbett
  Jack Corbett
SSC-Forever
SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)

Group: General Forum Members
Points: 43409 Visits: 14925
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
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

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
joepacelli
joepacelli
SSC-Addicted
SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)SSC-Addicted (466 reputation)

Group: General Forum Members
Points: 466 Visits: 291
I changed the cache from FULL to partial and that resolved it.

Can anyone explain this?
Jack Corbett
  Jack Corbett
SSC-Forever
SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)SSC-Forever (43K reputation)

Group: General Forum Members
Points: 43409 Visits: 14925
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
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search