Stored Procedures Vs. Views

前端 未结 7 1459
难免孤独
难免孤独 2020-12-07 16:26

I have used both but what I am not clear is when I should prefer one over the other. I mean I know stored procedure can take in parameters...but really we can still perform

7条回答
  •  清歌不尽
    2020-12-07 17:11

    Well, I'd use stored proc for encapsulation of code and control permissions better.

    A view is not really encapsulation: it's a macro that expands. If you start joining views pretty soon you'll have some horrendous queries. Yes they can be JOINed but they shouldn't..

    Saying that, views are a tool that have their place (indexed views for example) like stored procs.

提交回复
热议问题