Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Rand() value as a set not a cursor or loop

Status
Not open for further replies.

RobS23

Programmer
Jun 4, 2001
161
GB
Hi Guy's,

How do I insert generated values as a set and using not using a loop or cursor?

THere was a work around in 2000 but I've been out of the loop for a while and now I'm catching up on 2005 and can't seem to get it working.

Let me illustrate.

I select a name from a table and insert it into a new table with a randomly generated number. For simplicities sake let's just assume

Insert NewTable (Name, Random)
Select Name, Rand() from NameTable

The result would be.

John 0.212
Jane 0.212
Wayne 0.212

NOw how do I go about generating Rand() per row rather than per table?

Cheers!
 
Select Name, Rand(checksum(newid())) from sysobjects
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top