• Abu Dina (2/15/2013)


    Jeff Moden (2/15/2013)


    byecoliz (2/15/2013)


    thank you all for that new code. Abu Dina, you're right on the return correction. Now when i do that correction the function removes only the 'A' vowel., meaning the increment is not working.how can I organize these statements so that the increment works. thank

    Forget the code that increments. Do it the way that Lynn suggested. It will be much faster than any scalar function that you can write.

    Unless it's a SQL CLR C# UDF surely?

    Well I guess it depends on what the UDF needs to do. I recently posted a question about a SQL scalar function I had which contained over 200 IF statements. It was performing like a pig and I couldn't see a way of converting it to an iTVF so I write it in C#. The result? the C# version was 100 times faster than the SQL equivalent.

    I agree... properly written CLRs are usually much better at string handling. But they're not a panacea of performance and, speaking as a consultant, they're absolutely worthless if the shop you happen to be working in doesn't allow CLR. In this case (the vowel removal problem), you might find that the properly written iTVF function will be very nearly or just as performant as a CLR function.

    I've also found that if a function has over 200 IF statements, that it's time to go back to the drawing board. Many such "hopeless" functions frequently do have a much more effective and easy to code solution. there may also be the case where a stored procedure is more appropriate than a function.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)