You'll need to play about with the RAND() bit as I was getting back NULL
some of the time. But this assigns the value of @one, @two or @three to
@theOne.

        DECLARE
                @one INT,
                @two INT,
                @three INT,
                @theOne INT

        SELECT
                @one = 1,
                @two = 2,
                @three = 3

        SELECT @theOne =
                CASE CAST(RAND() * 4 AS INT)
                        WHEN 1 THEN @one
                        WHEN 2 THEN @two
                END

        SELECT @theOne


Ade

-----Original Message-----
From: Robertson-Ravo, Neil (RX)
[mailto:[EMAIL PROTECTED]
Sent: 17 July 2003 12:19
To: '[EMAIL PROTECTED]'
Subject: [ cf-dev ] random variable selection..


I am having a real brain fuzz this morning....
anyone got an example of how I can create an sp which has say 10 predefined
vars in it :

a,b,c,d etc..... and then runs a routine to select a random one?


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to