开发者

SQL Server view or table-valued function? [duplicate]

This question already has answers here: reuse sql with view or function (4 answers) Closed 9 years ago.

Anyone have a good decisioning tree for deciding when to use a view and when to use a table-valued f开发者_StackOverflowunction in SQL Server?


Although any view can almost trivially be converted to an inline table-valued function, the converse is not true.

If the construct needs to be parametrized, then use an inline table-valued function. Inline table-value functions are basically parametrized views in terms of the optimizer being able to combine them with views and push things around. Multi-statement table-valued functions are not at all like inline table-valued functions.

If you cannot do it with an inline table-valued function, use a multi-statement table-valued function.


There's certain things you can't do in a view (such as table variables, intermediate results before you return your result-set, etc.) ... if you don't need those, view, if you do, sproc/udf :-)


Ok, I'll give the use we do. We have the tables, but we never access the tables, but the views about the tables. It's just a security issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜