Functions & Stored Proc
Since solving any reasonable SQL problem requires a combination of all the topics covered here, hence it becomes difficult to segregate problems based on one topic alone. So, for SQL we are creating a dedicated Problems section. Theoretical and Basic questions will still be under their dedicated sections.
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.
Last updated