Clustered Index not ordering as it should. Why?

  • I was just trying different things as I'm going through a book and created a table called brokers

    fname varchar

    lname varchar

    email varchar

    lname, fname is a clustered index

    email is the unclustered primary key

    when I "SELECT * FROM brokers" it sorts by email??? If I remember right, everything I've read says that a table will be sorted by the clustered index.

    If I create the same table with an identity column as a non-clustered primary key it sorts just as it should using the clustered index.

    Why does using a varchar/char for a primary key make my clustered index sort different?

    thanks,

    Chuck Dearbeck

  • A partial explanation is that without an explicit order by you're not guaranteed to receive the data in a particular order regardless of whether you have a clustered index or what columns are in the clustered index.

    Andy

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

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