I have a SQL function (let's call it MyFunction) which retrives a list of column's names. The output is like col1,col2,col3...
The number of columns may vary. Minimum is one but can be much more.
With the use of this function I'd like to create a stored procedure which when executed, creates a dataset with distinct values for col1, col2, col3...
Something like:
select distinct
col1,
col2,
col3
....
from MyTable
It's like a dynamic dataset, which can have different number of columns.
How to fetch this function to the stored procedure?