I have 2 tables: Items & Users.
Items contains ItemID, and Num_Users
Users contains UserID
For each ItemID, I need to randomly select a number of Users according to the value stated in the Num_Users column.
I created a sample set of data on SQL Fiddle.
One way. SQL Fiddle
You could also use
CRYPT_GEN_RANDOM(4)instead ofNewid()for a greater degree of randomness but there are some issues with this on non up-to-date versions of SQL Server 2008.