Call TVF on each table entry and compelling results

I thought this should be obvious, but I cannot understand.

Let's say that there is a table tblDatawith a column IDand a table function ( _tvf) that takes a parameter ID. I need results for all ID's tblData.

But:

SELECT * FROM tblData data 
INNER JOIN dbo._tvf(data.ID) AS tvfData
   ON data.ID = tvfData.ID

gives me an error: The multi-part identifier "data.ID" could not be bound

What is the correct way to transfer all IDs to this TVF and reconcile the results?

thank

+1
source share
1 answer

I think you might need to use CROSS APPLY instead of an inner join here:

SELECT * 
FROM dbo.tblData data 
CROSS APPLY dbo._tvf(data.ID) AS tvfData

TVF data.ID .

. :

+5

Source: https://habr.com/ru/post/1770707/


All Articles