• no insults, just help with the logical rules of thumb for procedures and functions:

    avoid loops whenever possible: that's cursor, while loops whatever;

    like everything in SQL, there's more than one way to do anything, and anything set based is going to be faster...i try to think that SQL can handle a SET of Data in exactly the same amount of time it would take to process a single row.

    kind of like moving one apple vs a box of apples...handing it to the next process is the same amount of time.

    my examples are probably pretty good, but i'm always ready for a better technique than i'm throwing out there.;

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!