I am trying to apply a join between a table and a scalar-valued function. I have been investigating and I think that it is not possible, but as I do not find any final conclusion saying that I want to be sure.
Do you know if it is possible?
I tried the following statement (do not work):
Select *
from T1
join SVFunction on T1.id=SVFunction.id
And also this one (do not work):
Select *
from T1
outer apply SVFunction (T1.id)
Thank you.
You have to try the following query
Select * ,SVFunction(id)
from T1
Scalar valued function return single value (not table) so you cannot use joins.
If it is a table valued function you can use the following as another way then Using Apply
:
Select T1.* ,T2.*
From T1 INNER JOIN (SELECT * FROM SVFunction) AS T2 ON T1.id = T2.id
And Maybe the problem is in the function code. so you can read more about Using Apply in this Technet topic
Select *
from T1
JOIN (VALUES(SVFunction)) f(id) on T1.id=f.id
SELECT * FROM (SELECT SVFunction () as id) join T1 on T1.id = SVFunction.id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.