Differences Between SQL Server Foundation SQL stored procedures and functions

Source: Internet
Author: User

The

is no different in nature. Just a function like: Only one variable can be returned with a limit. A stored procedure can return more than one. Functions can be embedded in SQL and can be called in Select, and stored procedures do not work. The essence of execution is the same.  
     functions are more restrictive, such as the inability to use temporary tables, only table variables. There are also some functions that are not available, and so on. The limit of the stored procedure is relatively less  
      1.    in general, the function of the stored procedure implementation is more complicated, and the function is more specific in its implementation.  
      2.    can return parameters for stored procedures, and functions can only return values or table objects.  
      3.    stored procedures are typically performed as a separate part (exec execution), The function can be called as part of a query statement (select Call), since the function can return a Table object, so it can be in a query statement after the FROM keyword. &NBSP
      4.    when stored procedures and functions are executed, SQL Manager will go to procedure Cache to fetch the corresponding query statement, if there is no corresponding query in the procedure cache, SQL Manager will compile the stored procedures and functions.  
      Procedure Cache is an execution plan (execution plan) that executes Procedure when it is compiled. The execution plan in the cache, after which SQL Server will consider whether or not to save the plan in the cache based on the actual situation of each execution plan, the standard one is the frequency at which the execution plan may be used The second is the cost of generating the plan, which is the time-consuming compilation. The plan saved in the cache will not be compiled the next time it executes.

SQL Server Foundation SQL stored procedures and functions are different

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.