I'm trying to set a 4-digit password between 1234 and 9999 for those rows that don't already have a password.
My first attempt uses the following code.
begin tran
DECLARE @Lower int
DECLARE @Upper int
SET @Lower = 1234 -- Lowest password value
SET @Upper = 9999 -- Highest password value
update DestinationComparisons
set Password = ROUND(((@Upper - @Lower - 1) * RAND() + @Lower), 0)
where Password = '' or Password is null
commit tran
go
However, this seems to give me the same 4 digits for every row that is updated. Obviously, I'd like a different password for each row.
Can someone help me see what I'm missing?