What is the difference between Userdefined function and
stored procedure? Explain and give the example also

Answer Posted / ashwini

1. User defined functions can be used in select statements.
Procedures can not be used.

2. Functions must return some value. Procedures do not
always return the value.

3. Functions will take only input parameters. Procedures
can take input as well as output parameters.

4. Not all types of user-defined functions use
INSERT,UPDATE,DELETE statements(Only multi-statement table
valued functions can use). All procedures can use these
statements.

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the difference between delete table and truncate table commands? : Sql server database administration

518


I have all the primary data files, secondary data files as well as logs. Now, tell me can I still restore the database without having a full backup? : sql server database administration

676


What are the differences between union, intersect, and minus operators?

572


Can you pass expressions to function parameters?

532


What is the use of set nocount on/off statement?

626






What is cached report?

106


What is the importance of concurrency control?

662


How to get @@error and @@rowcount at the same time?

565


if no size is defined while creating the database, what size will the database have? : Sql server administration

542


Why are sql functions used?

616


How to enter unicode character string literals in ms sql server?

571


What are the two authentication modes in sql server?

600


What is index, cluster index and nonclustered index?

512


How do I start sql server 2017?

528


How can I check that whether automatic statistic update is enabled or not?

557