Is it possible to have a table-valued function in T-SQL return a table with a variable number of columns?
The column names may simply be 1, 2, …, n
.
Right now I have a "string split" function that returns a single-columned 1 x n
table, and I pivot the table afterwards to an n x 1
table, but I'd rather streamline the process by returning the correct table format to begin with.
I intend to use a CLR procedure in C# for this function, I just don't know how to set up the user-defined function to return my data in the format I want: with a variable number of columns, dependent on the input string.