views:

23

answers:

1

Here is my Query... Here I'm using a function Fn_getStagesForProject()... For which I need to pass the SWProjectID from Projects Table...

The function takes the ID as parameter and return all stages that corressponds to the project, on which I need to filer only the row that contains StageLevel as 0.

    Select  A.SWProjectID, 
        A.ShortTitle, 
        C.StageName as StageName,
        B.ExpectedCompletionDate as BudgetedReleaseDate
    From Projects as A 
            left outer join ProjectBudgets as B on A.SWProjectID = B.SWProjectID
            Left outer join Fn_getStagesForProject(Projects.SWProjectID) as C on B.StageID = C.StageID
    Where C.StageLevel = 0

The error is

The multi-part identifier "Projects.SWProjectID" could not be bound.

I tried changing it to A.SWProjectID, but I still get the error...

Thanks in advance for your help. Let me know, incase you need the Table Structure

  • Raja
A: 

Change LEFT OUTER JOIN Fn_getStagesForProject to CROSS APPLY Fn_getStagesForProject.

Anthony Faull
Thank you... I learnt something new today :-)
The King