I have an in-line function called myfunc
and it returns a TABLE
.
I can select certain columns from the function like so:
SELECT col1, col2, coln FROM myfunc()
However, is it possible to dynamically change the SELECT columns based upon a different table? We can assume the other table has all available column names (no typos, etc.)
Something like:
SELECT (SELECT available_cols FROM <other_table>) FROM myfunc() --pseudo code
It looks like this can be achieved using the EXEC
command but I'm curious if this can be baked into the SELECT command from the get-go.
Thank you.