Opps, this will work better...
DECLARE
@one INT,
@two INT,
@three INT,
@theChosenOne INT,
@var INT
SELECT @one = 1, @two = 2, @three = 3
SELECT @theChosenOne =
CASE SELECT CAST(RAND() * 3 AS INT) + 1
WHEN 1 THEN @one
WHEN 2 THEN @two
WHEN 3 THEN @three
END
SELECT @theChosenOne
I get back 1, 2 or 3 now
Enjoi
Ade
-----Original Message-----
From: Adrian Lynch [mailto:[EMAIL PROTECTED]
Sent: 17 July 2003 12:37
To: '[EMAIL PROTECTED]'
Subject: RE: [ cf-dev ] random variable selection..
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]
--
** 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]