Is there any way to call a stored procedure in multi scalar table-valued function like that?
Note: this query returns error:
Functions can't have side effects i.e. change data.
Even if your stored procedure doesn't change anything, the SQL compiler can't assume that, So it just doesn't allow it.
Why do you need to wrap this in a function?