I have a query with a CTE that returns multiple rows, I want to execute a Function for every row returned.
Is it possible, I checked on google, it says about using temp table to populate the result. I just want to confirm
with job_list as ( select JOB_ID,CREATED_DATE from job_table) ,
app_list as (select APP_ID from job_list jobs, dbo.fnGetApp(jobs.JOB_ID,9))
select * from job_list, app_list
This is not the exact query, I have simplified for understanding the problem I face.
dbo.fnGetApp is a function that takes two params varchar and int and returns a table of a single column (varchar APP_ID)
Error – The multi-part identifier “jobs.JOB_ID” could not be bound.
I want to run the function for every row returned by the job_list CTE and use the results as a CTE for another query which uses both the CTEs
Thanks
David
Can’t you do it like this: