• Koen Verbeeck (10/25/2013)


    chandan_jha18 (10/25/2013)


    Koen Verbeeck (10/25/2013)


    It might depend on indexes, the physical location of the rows in the pages and how the query plan is generated.

    Let's assume it's "random" unless you specify another column in your ORDER BY.

    By the way, that's a pretty lousy ID 🙂

    I second that the ID is pretty lousy:-)

    However, I do have a question here. Eve though a clustered index sorts the data physically but still it is recommended to use an Order by clause always if the data needs to be sorted. so what do you mean by 'depends on indexes'. Kindly explain.

    A clustered index does not sort the rows physically in the pages, but logically.

    Does a Clustered Index really physically store the rows in key order?[/url]

    What I meant with my statement was that if no ORDER BY is specified, the order of the rows fetched can be influenced by the indexes that are used in the query plan.

    If you want a specific order for some reason, use ORDER BY. If you don't, or don't specify enough columns in the ORDER BY, do not expect any specific order.

    Agreed. My mistake in mentioning that.

    thanks

    Chandan