• steve-lauzon (4/6/2010)


    Hi all... this is my first post in the forums. I hope I'm following the guidelines

    I need help!

    I got a table that contains a list of several regions (RegionName, Min, Max, NumberToGenerate)

    Ex : Region 1, 0, 5000, 100

    Region 2, 1700, 2300, 50

    I need to generate randomly X numbers (numbertogenerate) within the specified scope (between min and max) for each region

    After the number is generated, I have to check in another table to see if that number exist and if it does, add it to a ListedTable and if not, to a NonListed table. There are several other conditions to check but for the sake of this example, I'll keep it simple 🙂

    I have to loop within the specified region until I reach the listed numbers to generate. When reached, I move to the next region

    I tried using cursors which works fine but really slow.

    I have no clue how to conceive that procedure using batchs - I'm missing something.

    I know you have limited information, but I would appreciate some hints. I can give more info if needed

    Thanks

    Ummmm.... why does this need to be done randomly? I'm asking for two reasons... does it really need to be done randomly and there are several methods to pull this off randomly.

    Also, take a peek at the first link in my signature line below... it would help us help you a whole lot faster.

    --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)