• PRR.DB (7/22/2013)


    If table doesn't have clustered index , there is no guarantee for order , if table having clustered index then result will display clustered index column order.

    Is my answer correct or not? Can any one explain on it?

    --Example query.......

    USE tempdb

    GO

    create table Orderby(ID int)

    go

    insert into Orderby

    select 1

    union all

    select 2

    union all

    select 5

    union all

    select 4

    union all

    select 3

    union all

    select 7

    union all

    select 6

    go

    select * from Orderby

    go

    CREATE CLUSTERED INDEX [ClusteredIndex_Order1_ID] ON [dbo].[Orderby]

    (

    [ID] ASC

    )

    go

    select * FROM Orderby

    GO

    DROP TABLE Orderby

    GO

    I think i am correct in saying that as this is a very simple query the order will be that of the clustered index.... but in reality its however the execution plan spits out the rows. For this example the execution plan would just scan the table so it would be in CI order.