3
Reply

Difference between Function and Stored Procedure?

    You can find good comparison over here: www.c-sharpcorner.com/article/stored-procedures-vs-user-defined-functions-and-choosing-which-one-to-use/

    Stored Procedure :- 1.) Can take input \output parameter. 2.) can return zero,single or multiple rows. 3.) can use DML,DDl staements. 4.) can use non-deterministic function like getdate() 5.) use transaction 6.) use try-catch block 7.) use function inside stored procedureFunction : 1.) use only input parameter. 2.) must return a value. 3) use only DDL staement. 4.) cannot use try-catch block 5) cannot use transaction 6) cannot use stored procedure inside function

    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. Inline UDF’s can be though of as views that take parameters and can be used in JOINs and other Rowset operations.