THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Rob Farley

- Owner/Principal with LobsterPot Solutions (a MS Gold Partner consulting firm), Microsoft Certified Master, Microsoft MVP (SQL Server), APS/PDW trainer and leader of the SQL User Group in Adelaide, Australia. Rob is a former director of PASS, and provides consulting and training courses around the world in SQL Server and BI topics.

SSIS Lookup transformation in T-SQL

Hi! - Great that you've found this page, but it's no longer here! You can find the content over at:

Published Tuesday, July 8, 2014 6:56 PM by Rob Farley

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS



Surjit said:


I had below doubt on second outer apply

 When there is condition d1.BusinessKey IS NULL

 How can this cindition execute "AND d.BusinessKey = f.DimBK "



July 16, 2014 4:51 AM

Rob Farley said:

Hi Surjit,

The first predicate is on the set d1, which is reflected in the Startup Filter. It means it only does this lookup if the first one (d1) has failed to find something.

The second predicate is on the tables d and f, and is used to find the record in the dimension table.

Does this help?


July 16, 2014 5:03 AM

Tarek said:

Hi Rob,

your post helped me a hell lot. I was trying to solve a similar scenario where I wanted to build a parent child table structure and I only knew that the parent is the next of the preceding elements in the list with HierarchyLevel-1. By changing the join that I made first your APPLY statement and constraining my resultset to TOP 1 DESC, I obtained exactly my desired result. Otherwise, by use of a common join I would have gotten as much duplicate rows as much rows of lower level were found in the list before.

Thanks a lot!

Best regards,


May 21, 2015 8:42 PM

Rob Farley said:

That's great, Tarek! :)

May 21, 2015 9:36 PM

dsad said:


October 27, 2017 1:31 AM

Leave a Comment


This Blog



No tags have been created or used yet.


News? Haven't you read my blog?

My Company

Can't find something?

Contact Me

Twitter: @rob_farley
Skype: rob_farley

MVP (SQL Server)


Adelaide SQL UG

Privacy Statement