SQL Server: Table-valued Functions vs. Stored Procedures

前端 未结 2 1837
傲寒
傲寒 2020-12-09 15:11

I have been doing a lot of reading up on execution plans and the problems of dynamic parameters in stored procedures. I know the suggested solutions for this.

My que

2条回答
  •  天涯浪人
    2020-12-09 15:32

    I haven't verified this, but I take for granted that the execution plan for functions are also cached. I can't see a reason why that would not be possible.

    The execution plan for views are however not cached. The query in the view will be part of the query that uses the view, so the execution plan can be cached for the query that uses the view, but not for the view itself.

    The use of functions versus stored procedured depends on what result you need from it. A table-valued function can return a single result, while a stored procedure can return one result, many results, or no result at all.

提交回复
热议问题