INNER JOIN with Table-Valued Function not working INNER JOIN with Table-Valued Function not working sql-server sql-server

INNER JOIN with Table-Valued Function not working


With the table valued function you generally use Cross Apply.

Select *From myTable mCROSS APPLY fn_function(m.field1, m.field2)


If we made some assumptions that params of table valued functions are not dependent on myTable columns dynamically this will work.

   SELECT *    FROM myTable     INNER JOIN    (SELECT * from fn_function(@para1, @para2 etc)) ON ...

but if the params are dependent on myTable it will not work


Your "ON" clause of the join is most likely incorrect. Perhaps a small typo like

JOIN x ON oID = odID

instead of

JOIN x ON oID = oID