By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,743 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,743 IT Pros & Developers. It's quick & easy.

Clustered index not working

P: n/a
Jim
I put a clustered index on a table with 2 columns

-nationalityid int autoincrement PK

-nationality varchar(50)
the clustered index is on nationality

however; when i do a select i still get a record set back ordered by
the nationality id...what am I doing wrong?

-Jim
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Jim" <ji********@motorola.com> wrote in message
news:72**************************@posting.google.c om...
I put a clustered index on a table with 2 columns

-nationalityid int autoincrement PK

-nationality varchar(50)
the clustered index is on nationality

however; when i do a select i still get a record set back ordered by
the nationality id...what am I doing wrong?

-Jim


When you do a SELECT, you must specify ORDER BY if you want the result set
to be in a certain order. Even with a clustered index on a table, there is
no guarantee that you will get your results in any specific order.

Simon
Jul 20 '05 #2

P: n/a
Hi ,
The clustered index is usually set on in the primary key field.The
query optimiser selects the records and displays as per the P.K Field
by default ascending.

Since u have CLUSTERED INDEX which is a non P.K field , U hadthe
problem.
Generally , Clstered index is only used for the sake of speed fetching
..
I thing my words clear.
Raghu
India
Jul 20 '05 #3

P: n/a

"Raghuraman" <ra************@rediffmail.com> wrote in message
news:66**************************@posting.google.c om...
Hi ,
The clustered index is usually set on in the primary key field.The
query optimiser selects the records and displays as per the P.K Field
by default ascending.

"Maybe".

Without and ORDER BY there is no guarantee what order you will get stuff
back in.

Now, in most cases you may see the behaviour you describe, but I would not
count on it.
Since u have CLUSTERED INDEX which is a non P.K field , U hadthe
problem.
Generally , Clstered index is only used for the sake of speed fetching
.
I thing my words clear.
Raghu
India

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.