|
Which one is the best in following :- Using sub query or function in stored procedure?
(comments are locked)
|
The question has been closed Jul 20 '10 at 05:55 AM by Grant Fritchey for the following reason:
|
It depends on the result? What do you want the subquery or function to return? If function is well written, and as inline, if runs very fast. If you write your subquery basd, you can end up with some real RBAR.
(comments are locked)
|
|
You can use both equally poorly or well. I could write a function which was lightning quick and a sub-query that was slow, or vice versa. This question, therefore, can only really be answered for a specific scenario, so if you want some help with a specific requirement, then please let us know that requirement and we'll undoubtedly be happy to help.
(comments are locked)
|
|
What is your criteria for best? Are you looking for performance or maintainability? Functions 'usually' take a performance hit but are easier to reuse.
(comments are locked)
|


I'm tempted to close this question - the answers below ('it depends') pretty much cover it, and anything more specific should really be another question.
I would tend to agree - might be worth giving the guy a while to clarify though?
I agree as well Matt. Leave it up for 24 hours to span timezones and give the requestor time to respond and also check for down votes.