문제

This is a little tricky to describe, but hopefully there is a solution.

I have a UDF which takes an ID and returns a table. Is there a way I can do a SELECT for these IDs and perform a UNION of the UDF results? For example;

To get the IDs;

SELECT [ID] FROM [TableOfIDs]

To get the object properties from an ID;

SELECT * FROM GetObjectProperties(@ID)

But how do I combine the two? That is, to do a union of the UDF results from a query for the IDs?

I hope that makes sense!

도움이 되었습니까?

해결책

You need to use APPLY:

SELECT TT.* 
FROM [TableOfIDs] AS T CROSS APPLY GetObjectProperties(T.ID) AS TT;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top