• Well, hello there.

    Luis - thanks for linking to my article. However, I'm afraid that it doesn't do much for helping to learn how to remove cursors. For that task, my favorite articles can be found here[/url] - it should be obvious which two articles I'm referring to.

    priestxandar - This latest cursor-ridden function just makes we want to say "OMG". For several reasons.

    1. It's a scalar function. These don't scale well (nor do multi-statement table-valued functions). Please read this blog post[/url] for more information. If you can convert these scalar functions to inline table-valued functions, your server will be able to take a deep sigh of relief.

    2. We don't have the definitions for the views that are referenced. Please script out and post the DDL for the views vw_CallForTender, [vw_Bid_Criterias] and any other views referenced in this function.

    3. How are these functions being used? If you can include those queries, I bet we can make the entire process even better!

    4. Luis and I both have links in our signatures for how to post data to get better help. It really does make a difference. Please do this. Or...

    5. Consider hiring someone (like myself) to look at your system and re-write this code. It seems like you are in over your head, and this may well be the better method.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2