Sorting results randomly

Results 1 to 2 of 2

Thread: Sorting results randomly

  1. #1
    Join Date
    Dec 1969

    Default Sorting results randomly

    Using MS SQL Server, is there a way to sort the results of a query randomly? I&#039;ve tried the Rand() function, and as the help file states, it will generate the same value when used in the same query. I&#039;ve even tried the example of...<BR><BR>Rand( (DATEPART(mm, GETDATE()) * 100000 )<BR> + (DATEPART(ss, GETDATE()) * 1000 )<BR> + DATEPART(ms, GETDATE()) )<BR><BR>...that they give in the help file, but I still get the same number on all rows. Is there any way that anyone&#039;s aware of that I can sort results randomly?<BR><BR>Thanks,<BR>Jesse

  2. #2
    Join Date
    Dec 1969

    Default RE: Sorting results randomly

    You can order on NewID()<BR><BR>Books online has more information.<BR><BR>Craig.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts