Select to get Random list

  • I need to run a query that will get a random list of ids from a table. I was thinking of using the newid() function. The following is an example of the query I could use:

    select top 20 id

    from cases

    order by newid()

    This seems to work and if indeed this really gives me a truly randomized list, then I need to document how the newid() function works. A white paper on the function would be nice, but I can't find one.

    So, can anyone help with this. I need to be able to support my query for getting the selected list so that it can be approved by a state organization.

    Thanks,

    Chase

  • I am not aware of any whitepapers on the newid function and the only documentation that I have seen is in books online.

    However if you want to write up your own, this post has some pretty good discussion of creating a random list using the NewID function (post 2 on).

    http://www.sqlservercentral.com/Forums/Topic666309-338-1.aspx

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply