SQL Server Order by

  • Hi all,

    I have the table with follwing structure

    ID( Forgein key ),

    UpdatedTime DateTime,

    .....

    I inserted two records with two same datetime and other parameters differs

    but when i am selecting based on Datetime field it does not displays in the order which i have inserted(duplicate datetime) .

    I Applied index for ID and UpdatedTime .How do i get the order in which i inserted and also by [DateTime]?

    Thanks in Advance

  • Unless you have a field that tracks the order that records are inserted )and is used to help order) and the columns you are sorting on are duplicates, there is no guarantee that the records will be returned in the order entered.

  • Lynn Pettis (7/9/2009)


    Unless you have a field that tracks the order that records are inserted )and is used to help order) and the columns you are sorting on are duplicates, there is no guarantee that the records will be returned in the order entered.

    Glad I gave basically the same answer on this thread.

  • Jack Corbett (7/9/2009)


    Lynn Pettis (7/9/2009)


    Unless you have a field that tracks the order that records are inserted )and is used to help order) and the columns you are sorting on are duplicates, there is no guarantee that the records will be returned in the order entered.

    Glad I gave basically the same answer on this thread.

    Well, you know what they say about great minds, right? 😉

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

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