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

List the types of recovery model available in sql server?

665


What are SSL and TSL protocols?

747


Do you know what is a with(nolock)?

790


Can group functions be mixed with non-group selection fields in ms sql server?

700


How many categories of functions based their return modes?

844






What are system databases into sql server (2005/2008) : sql server database administration

760


Explain log shipping?

768


How extra digits are handled with numeric data type literals?

693


Can we use where and having clause together?

708


Can two tables have the same primary key?

862


What is difference between materialized view and view?

686


What functions can a view be used to performed?

794


Why would you call update statistics?

754


What does it mean to normalize a database and why would you do it?

725


what data regions are and what are the different data regions?

115