Before than i will give the design and data,
I forgot for I think important issue, If this function is using for example inside 20procedures, it can causes this problem? For example lock or something ?
Because I created new one and without relation in another procedures and this is 2ms... BUT like I wrote above, if I will started this function two times in same time, the second will be 2ms, but first 25ms.
I will try on the break time delete execution plan.
txh for reply