• Mani Singh (6/21/2008)


    you can use this and manipulate this query to code as needed..

    DECLARE @GENRANDOM nvarchar(9)

    SET @GENRANDOM =LEFT(SUBSTRING (RTRIM(RAND()) + SUBSTRING(RTRIM(RAND()),3,11), 3,11),9)

    --SELECT SUBSTRING(@GENRANDOM ,3,1)

    SELECT @GENRANDOM as 'RANDOM_NUMBER'

    Yep... you could do that... if the serial numbers were truly random. But I don't believe that's what's actually being asked for even though the word "Random" was used in the request. I believe the OP wants weekly repeating serial numbers. 🙂

    Also, how does your code keep from generating the same random number during the same week? 😉

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