Showing the records random

  • Dear All,

    I'm looking for a way to query the table's records absolutely in random in different times.

    As you know when the records of a table retrieved by a query the result is ordered based on the value of a column as see the first column.

    Would you please showing me how I can achieve to this problem.

    Sincerely yours

  • Actually, the only way you can guarantee the order in which SQL Server will return the rows is to use the ORDER BY clause. All SELECT statements without an ORDER BY are not ordered, even if they appear to be. This sounds a bit homeworkish. Can you expand on what you are trying to accomplish by returning a randomly ordered result set? In fact, why don't you post some sample data and and example of how you want to see the results. Please include any attempts that you have made to do this.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • John is right, we want to see some attempt.

    As a hint, think NEWID()

  • Some "hint" Steve - that looks suspiciously like an answer to me.

  • If it wasn't then, it sure is now. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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