home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 19,135 of 19,505   
   Erland Sommarskog to Jim   
   Re: CASE issue   
   29 Nov 14 10:43:01   
   
   From: esquel@sommarskog.se   
      
   Jim (jgeissman@socal.rr.com) writes:   
   > I believe RAND() is evaluated once at the beginning, while NEWID() is   
   > evaluated each time. So one solution would be to evaluate the NEWID()   
   > version and park the result in a variable and use the variable, or use   
   > RAND() but base it on a seed that doesn't involve NEWID(), or at least   
   > if it does, determine it outside of the CASE statement.   
   >   
      
   I don't think that would work well, because you want a new random number   
   per row. You could use a column on the row as seed - but then it would   
   be deterministic. Look at this.   
      
   SELECT rand(), rand(object_id) FROM sys.objects   
      
      
   --   
   Erland Sommarskog, Stockholm, esquel@sommarskog.se   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca