Sean Lange (4/18/2014)DDL, sample data and desired output would go a long way to getting you an answer. It is not at all clear what you mean by putting an outer apply inside another outer apply.

Maybe I am going about this wrong.

The 1st query gives me what I want and I'm trying to add the next piece in.

Here is the result of the 1st query:

EID AgentID info.emailIDsql123 59231 Sqlraider.Syntax

Now I need to take Sqlraider.Syntax and add '@company1.com' to it for: 'Sqlraider.Syntax@company1.com'. Using this I need to read another table were I could have none, one, or many in the results but I only need the Top 1. Pulling the information from that row.

I don't know what info.emailID is until the 1st Outer Apply executes so I don't what I need to achieve my desired results. I do know that if I put the 1st query in a temp table and then run the 2nd Outer Apply against it I'd get the desired results but I want to achieve this in one query not two if possible.

To paraphrase what Sean has already said, please provide CREATE TABLE scripts for all of the relevant tables, INSERT Statements to populate those tables with test data, and and example of what the desired output will look like.

This will make it much easier for us to understand your situation and the result you're trying to achieve.

Prosecutor James Blackburn, in closing argument in the "Fatal Vision" murders trial: "If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them."

Sorry it to so long to reply...been putting out fires over the weekend.

This is what I was looking for and gets me the desired results.

Thanks,Sqlraider

Great, glad it helped!

SQL DBA,SQL Server MVP('07, '08, '09)

Prosecutor James Blackburn, in closing argument in the "Fatal Vision" murders trial: "If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them."