Lookup Question

  • 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

  • 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-64B4A2315762999-8177

    So the data exist.

    Why is it going to my error output?

    Joe

  • 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.

  • I changed the cache from FULL to partial and that resolved it.

    Can anyone explain this?

  • 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.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply