So I have a query that gives me some analysis on the values in a column, in a table. It reurns a small data set.
It gives me the max, min, stdev, avg and some other stats grouped by another column.
I wanted to create a table valued function from the query, so I could do the same analysis on any numeric column, in any table. I would just pass in the column name and the table name as paramters to my table-valued function and it would return the data set. Then I could join to it and use in other queries.
I thought I would build my query using dynamic SQL and execute it within the function, but I got an error and learn that you can not use execute in a function.
I have never created a CLR function, would this be possible to do it this way? This would be a decent sized step for me, but am willing to learn if possible. Or does anyone know how to solve this problem?
Problem: Pass column name and table name into function and have it reurn a dataset. Use the dataset as a table in other queries, scripts or procedures like a table valued function.
Thanks,
Mike