Home Forums SQL Server 2005 T-SQL (SS2K5) Choosing the faster option; Stored Procedure or Function? RE: Choosing the faster option; Stored Procedure or Function?

  • Thanks for the confirmation. I reached the conclusion after trial and error that a long query with all elenments within the select statment was faster than an beautifully written one that referred complex calculations out to functions. I just have no experience of functions and optimisation to back up my 'best-performance' structure.

    Apart from the benefit of a common code segment placed in a Function I now don's see any benefit in using them. I went so far as to test a few other Stored Procedures that used the complex calculation function - where I copied the exact code in the function back into the procedure - and in every case the procedure ran faster than when the code used the function.

    If there are any articles out there that explain the actual workings where a function is more efficient please point me to this. I still like the concept of encapsulating repeated code elements in functions but the penalty in performance is a concern.

    As far as using CLR goes it will not work in this case because the calculation is using columns of 2 tables.