What is the difference between Userdefined function and
stored procedure? Explain and give the example also
Answers were Sorted based on User's Feedback
1.A stored procedure is a precompiled collection of
Transact-SQL statements stored under a name and processed
as a unit that you can call from within another Transact-
SQL statement or from the client applications.
2.Stored procedure performs an action.
3.A collection of SQL statements often combined with
Control-of-flow statements.
1.User Defined Functions are compact pieces of Transact SQL
code, which can accept parameters, and return either a
value, or a table. They are saved as individual work units,
and are created using standard SQL commands. Data
transformation and reference value retrieval are common
uses for functions.
| Is This Answer Correct ? | 8 Yes | 0 No |
Answer / 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 |
1. function always run with select command while stored
procedure execute with execute command
2. function not provide output parameter facility
while stored procedure provide output facility
3. function always execute means it execute more than one
time while store procedure execute only one time
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / ashish
Please check out the below link. I think it may be useful:
http://newtechnobuzzz.blogspot.in/2014/07/difference-between-user-defined-funtion.html
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / anil sharma
Userdefined function can used in select statement.
It must return a values but in store procedure it is
optional.
Store procedure can use using sqlparameter but in
userdefined function it is not used.
| Is This Answer Correct ? | 1 Yes | 2 No |
What happens if you delete a table that is used by a view?
Explain what you mean by 3 tier architecture.
What are different types of collation sensitivity?
I have Two table First have UserName and second is address, in address table more than value relegated to UserName table, i want to fetch 2nd address if exist other wise 1st address access
How do you implement session management in SQL Server mode?
What are the fixed server level roles? : sql server security
How will you monitor replication activity and performance? What privilege do you need to use replication monitor? : sql server replication
What are the different types of cursor?
how to retrive only second row from table in sql server 2000?
What is the use of commit?
Explain what is the main purpose of having conversation group?
Repair mdf file
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)