SQL Server Developer Center >
SQL Server Forums
>
SQL Server Integration Services
>
Conditional lookup
Conditional lookup
- I am using a lookup task to find values for a sales order table. The flat file I'm reading in may or may not contain a value for "customer contact". if the value is in the file, i need to use it. If not, I need to look it up in the customer table. Can I perform this logic using a lookup task only, or do I need to do somethinglike a conditinal split and then do two separate lookups?
John Schroeder
Answers
- Nitesh is correct.
No need to use the conditional split. Directly do the lookup and you get the records which match.
Another approach could be done as you said you have lot of lookups to be performed.
first dump the data from the text file to a staging table.
Use this table as the source and modify the source query by using joins to get the other column values.
This way you do not need to use the lookup task.
Hope this helps !!
Sudeep | My Blog- Marked As Answer byjschroeder Thursday, November 05, 2009 4:11 PM
All Replies
What do you mean by "If the value is in file"?
Please give some sample data
Nitesh Rai- Please mark the post as answered if it answers your question- here you can use a conditional split on customer contact.add an expression in conditional split as (trim([customer contact])=="" || ISNULL(customer contact))|----------------------| conditional split |-----------------------| |true Default| |lookup file customer contactcustomer contactif the above condition is true then use a lookup on customer table else ... :)Thanks-
Let us TRY this | Don’t forget to mark the post(s) that answered your question- Unproposed As Answer byjschroeder Wednesday, November 04, 2009 3:12 PM
- Proposed As Answer byBharani 3010 Wednesday, November 04, 2009 4:07 AM
Thanks for your response. Now let's say the problem is much more complicated and the import file contains dozens of fields that may or may not have a value and may or may not need a lookup. What I see with this type of solution is a very complicated tree that branches out to include all possibilities of empty and non-empty values. Is there a way to accomplish the import without using the conditional split method you suggest above?
John Schroeder- Why dont you directly use a lookup without a conditional split?
Any value (columns comming from source) that is null or blank will fail the lookup and will be redirected to a different path.
After this you can use the redirected rows and perform whatever opeartion is required.
Nitesh Rai- Please mark the post as answered if it answers your question - Nitesh is correct.
No need to use the conditional split. Directly do the lookup and you get the records which match.
Another approach could be done as you said you have lot of lookups to be performed.
first dump the data from the text file to a staging table.
Use this table as the source and modify the source query by using joins to get the other column values.
This way you do not need to use the lookup task.
Hope this helps !!
Sudeep | My Blog- Marked As Answer byjschroeder Thursday, November 05, 2009 4:11 PM
Thanks for your responses. Due to the complexities of my problem, neither the conditional split or the direct lookup method will work. I need to use Sudeep's suggestion of dumping the data to a staging table.
John Schroeder


