Functions & Stored Proc
Last updated
Was this helpful?
Last updated
Was this helpful?
Functions are calculated values that cannot make lasting modifications to SQL Server's environment (i.e., no INSERT or UPDATE statements allowed).
If a function provides a scalar value, it may be used inline in SQL queries; if it returns a result set, it can be joined on.
Functions must return a value and cannot change the data they receive as parameters, as defined by computer science (the arguments). Functions can't modify anything and must have at least one parameter. They also have to return a result. Stored procedures don't need a parameter, may modify database objects, and don't have to return a result.
Stored procedures are used to connect SQL queries in a transaction and to communicate with the outside world.