Stored Procedures vs Functions:
• We can go for transaction management in procedure whereas we can't go in function.
• Procedure can return zero or n values whereas function can return one value which is mandatory.
• Procedures can have input/output parameters for it whereas functions can have only input parameters.
• Inline UDF's can be though of as views that take parameters and can be used in JOINs and other Rowsetoperations.
• Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
• Functions can be called from procedure whereas procedures cannot be called from function.
• Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
• Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.
• UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
• UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
• And a lot more
here[
^].
And a lots of differences are there between function and sub in vb. Refer the links below:
Sub Procedures and Functions in VB.net[
^]
VB.Net Sub vs. Function[
^]
An Introduction to Functions and Subs[
^]
And a lot more
here[
^].
--Amit