Gossamer Forum
Home : General : Databases and SQL :

Password Problem

Quote Reply
Password Problem
Hi

I posted this question on another thread in the Links SQL Discussion but it is probably more relevant to this Forum.

Alex posted the following and it works for others but not me.

UPDATE Users SET Password = FLOOR(RAND() * 10000)


All I get is the same 4 digit number on every record.

I'm on a MS SQL Server, could this be the problem.?

Regards

minesite
Quote Reply
Re: [minesite] Password Problem In reply to
I'm not sure about this one. How about something like?

Code:
UPDATE Users SET Password = RAND(10000)

- wil
Quote Reply
Re: [minesite] Password Problem In reply to
You should be able to come up with something by reading here:

http://msdn.microsoft.com/...ac_8_con_11_1bl0.asp

Last edited by:

Paul: Apr 25, 2002, 7:32 AM
Quote Reply
Re: [Wil] Password Problem In reply to
Hi Wil

Getting closer but still gives me the same on all records.

Not this but like this:

0.794575



Regards

minesite
Quote Reply
Re: [minesite] Password Problem In reply to
Hi,

I don't think you can do this with MS SQL, the RAND() function gets only evaluated once, and then the update happens, whereas in MySQL, the RAND() is evaluated for each row.

You would need to use a script that:

SELECT Username FROM Users

UPDATE Users SET Password = FLOOR(RAND() * 1000) WHERE Username = $username

for each user.

Cheers,

Alex
--
Gossamer Threads Inc.