Hi,
Below are the basic differences between Functions and Stored Procedures in SQL Server.
S# | Functions | Stored Procedures |
1 | Functions must return a value | Procedures can return 0 or n values |
2 | Procedures cannot be called from Functions | Functions can be called from stored procedures |
3 | Functions allow only select statement in it | Procedures allow select as well as DML Statements (INSERT / UPDATE / DELETE) in it |
4 | Exceptions cannot be handled in Functions | Exceptions can be handled using try catch block in Procedures |
5 | Functions can be embedded in a Select statement | Procedures cannot be embedded in a select statements |
6 | Functions can have only input parameters | Procedures can have input / output parameters |
7 | Functions are not pre-compiled and they compile only during execution time. | Stored Procedures are pre-compiled |
Regards,
Selvaraj.