2
Reply

.NET and SQL Server Interview Question - Difference between Stored Procedure and Function?

Shivprasad Koirala

Shivprasad Koirala

13 years ago
4.8k
0
Reply

    1) Stored Procedure has input and output parameter but UDF has only input parameter. 2) We can use try catch block in SP but we can not use in UDF for handling error. 3) We can use DDL operation only in UDF but we can do DDL and DML operation in SP. 4) We can use UDF from SP but we can not use SP from UDF.

    Pramod Verma
    9 years ago
    0

    Answer:

    Function are compiled and executed at run time.
    Stored Procedure are stored in parsed and compiled format in the database.

    Function cannot affect the state of the database which means we cannot perform CRUD operation on the database.
    Stored Procedure can affect the state of the database by using CRUD operations.

    Store Procedure can return zero or n values whereas Function can return only one value.

    Store Procedure can have input, output parameters for it whereas functions can have only input parameters.

    Function can be called from Stored Procedure whereas Stored Procedure cannot be called from Function.
     
    Regards,

    Please click here to see more .NET and SQL Server interview questions

    Shivprasad Koirala
    13 years ago
    0