Is there any way to call a stored procedure in multi scalar table-valued function like that?
Note: this query returns error:
You cannot execute a stored procedure in a function.
I resolved this problem. I wrote a table-valued function including executable query, returns table and prepared an stored procedure to call that function passing parameters. It works for me.
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?