What is the difference function and stored procedure?



What is the difference function and stored procedure?..

Answer / Shoorbir Singh

Function and Stored Procedure are both used for encapsulating SQL code in SQL Server, but they have some differences:
1. Function is a collection of Transact-SQL statements that returns a single scalar value, table value or cursor as a result. It can be called from SELECT, INSERT, UPDATE and DELETE statements.
2. Stored Procedure is a prepared SQL code module saved in the database. It can contain one or more Transact-SQL statements and can return a single scalar value, table value or cursor as a result (like functions). However, it cannot be used within other SQL statements directly.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Difference between Function and Stored Procedure?

9 Answers   C1 India, NA,


Define constraints and give an example of their use?

1 Answers  


What happens if the update subquery returns multiple rows in ms sql server?

1 Answers  


How to encrypt Strored Procedure in SQL SERVER?

1 Answers  


What is normalization? Explain different forms of normalization?

1 Answers  


Explain features and concepts of analysis services?

1 Answers  


What is create command?

1 Answers  


What are different type of Collation Sensitivity?

1 Answers  


what is replication? where do u use Go Keyword?

1 Answers   Satyam,


What is a livelock?

1 Answers  


What is a constant or literal in ms sql server?

1 Answers  


Differentiate between a having clause and a where clause.

1 Answers  


Categories