Reputation: 77
As I am not so clear in scenarios of when to use stored procedures instead of functions ,
I have a scenario where a function is already being used, but as it takes much time to execute in a stored procedure, now can I replace this function (which returns a string) with a procedure?
Can any one please explain me what happens when replacing a function with a stored procedure?
Thanks in advance.
Upvotes: 0
Views: 1256
Reputation: 239704
There's no magically performance boost from either one. If they contain the same code, they'll have the same performance.
I'd say, keep it as a function unless or until you reach a limitation of functions - e.g. if you want to actually change database state.
Functions are more composable - you can call them directly from within other statements such as SELECT
- whereas stored procedures have to be explicitly called.
Upvotes: 2