What is the difference between a stored procedure and a view?

后端 未结 10 1930
星月不相逢
星月不相逢 2020-12-04 04:59

I am confused about a few points:

  1. What is the difference between a stored procedure and a view?

  2. When should I use stored procedures, and whe

10条回答
  •  借酒劲吻你
    2020-12-04 05:39

    @Patrick is correct with what he said, but to answer your other questions a View will create itself in Memory, and depending on the type of Joins, Data and if there is any aggregation done, it could be a quite memory hungry View.

    Stored procedures do all their processing either using Temp Hash Table e.g #tmpTable1 or in memory using @tmpTable1. Depending on what you want to tell it to do.

    A Stored Procedure is like a Function, but is called Directly by its name. instead of Functions which are actually used inside a query itself.

    Obviously most of the time Memory tables are faster, if you are not retrieveing alot of data.

提交回复
热议问题