For example, I want to be able to write function 'f()' that I can call as written below. (Note that @tbl is a user-defined memory table that I've previously created with columns Var1 and Var2, and that my function 'f' calls for a parameter of user-defined table type.)
SELECT t1.Var1, t1.Var2, f(@tbl) OVER (PARTITION BY t1.Var1)
From @tbl as t1
It seems like user defined functions will either return table values or scalar values. I need to be able to return a column though, because I want to apply the function over a given column by group.