Function | Store procedure |
---|---|
Function must return a value | Store procedure can return a value or no value |
Function can have only input parameters but no output parameters | Store procedures can have input parameters as well as output parameters |
A Function can be called in a store procedure | A store procedure cannot be called in a function |
Function only allows select statement | Store procedure allows select statement as well as DML(Insert,Update,Delete)statements |
Function can be used in a select statement | Store procedure cannot be used in the select statement |
Function are complied every time when called | Store procedure compiled only once in first call, After compilation store procedures are stored in memory and then called from the memory |
We cannot implement try catch block in functions | We can implement try catch block in store procedures |
We cannot manage transactions in functions | we can manage transactions in store procedures |
Saturday, 7 February 2015
Difference between Function and Store procedure
Labels:
Sql Server
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment