开发者

SQL complex unions

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 fo开发者_开发知识库r 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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜