Differences between functions and stored procedures?

Answer Posted / samba shiva reddy . m

1. Functions are compiled and executed at run time.
Stored procedures are stored in parsed and compiled format in the database(Pree compiled).

2. Functions cannot affect the state of the database which means we cannot perform insert,delete,update and create operations on the database.
Stored Procedures can affect the state of the database by using insert,delete,update and create operations.

3 Functions are basically used to compute values. We passes some parameters to functions as input and then it performs some operations on the parameter and return output.
Stored procedures are basically used to process the task.

4.Function can not change server environment and our operating system environment.
Stored procedures can change server environment and our operating system environment.

5.Functions can invoked from SQL Statements.
example : select udf from table name

Stored procedures can't invoked from SQL staements.
example : select spname from table name

6.Functions can run an executable file from SQL SELECT or an action query.
operating system use Execute or Exec to run

7.We can use User Defined function in Stored procedure
we can't use stored procedure in UDF.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you check the level of fragmentation on a table?

601


How to invoke a trigger on demand?

532


In which tcp/ip port does sql server run? Can it be changed?

535


What is the new security features added in sql server 2016? : sql server security

610


How many databases Microsoft SQL server provides?

598






What is transaction server implicit?

525


What does select 1 mean?

521


When cursors are useful?

570


Can we call future method from queueable?

586


What is constraints and its types?

490


What do you understand by a view? What does the with check option clause for a view do?

598


What is sparse columns of sql server 2008?

595


What is the purpose of a table?

510


How to change the password of a login name in ms sql server?

551


Explain the use of keyword with encryption. Create a store procedure with encryption?

529