What is difference between stored procedure & function?
Answers were Sorted based on User's Feedback
Answer / khurram
1>Procedure can return zero or n values whereas function can
return one value which is mandatory.
2>Procedures can have input,output parameters for it whereas
functions can have only input parameters.
3>Procedure allow select as well as DML statement in it
whereas function allow only select statement in it.
4>Functions can be called from procedure whereas procedures
cannot be called from function.
5>Exception can be handled by try-catch block in a procedure
whereas try-catch block cannot be used in a function.
6>We can go for transaction management in procedure whereas
we can't go in function.
7>Procedures cannot be utilized in a select statement
whereas function can be embedded in a select statement.
| Is This Answer Correct ? | 17 Yes | 3 No |
Answer / shreenath27@yahoo.co.in
function will return value but procedure will not return any
value
| Is This Answer Correct ? | 6 Yes | 4 No |
Answer / somu kattikar
Functions
----------
1) can be used with Select statement
2) Not returning output parameter but returns Table
variables
3) You can join UDF
4) Cannot be used to change server configuration
5) Cannot be used with XML FOR clause
6) Cannot have transaction within function
Stored Procedure
-----------------
1) have to use EXEC or EXECUTE
2) return output parameter
3) can create table but won’t return Table Variables
4) you can not join SP
5) can be used to change server configuration
6) can be used with XML FOR Clause
7) can have transaction within SP
| Is This Answer Correct ? | 1 Yes | 1 No |
Why is there a performance difference between two similar queries where one uses union and the other uses union all?
Give an example of SQL injection attack ?
Beginning with sql server version 7 0, a new enhanced data type nchar was added what type of data is supported with this data type?
Differentiate between delete and truncate.
What are sub-queries? Give example? In which case sub-queries are not feasible?
Can some one please help with a query which will take only max value of a column in a join.
Is sql server 2016 free?
what is the cursor life span?
default databases available in sql server and there uses ?
What is the concept of optimization?
How to define the name and server for a new dsn?
What are the differences between substr and charindex in sql server.
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)