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