Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SELECT USING INDEX

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-26 : 09:11:19
MARCOS writes "Hi,

I am having problems with select using an index.
I have created a table with constraint pk_table(data)
I have created an index with pk data.
when i do a "select * from table" , the data comes unordered.
what am i doing wrong ?

thanks ,

marcos."

Nazim
A custom title

1408 Posts

Posted - 2002-03-26 : 09:22:27
What kinda index is it Clustered or non-clustered.

in any case you can specifically sort it using order by clause in your query.



--------------------------------------------------------------
Go to Top of Page

MARCOSV
Starting Member

1 Post

Posted - 2002-03-26 : 09:33:51
WHEN I USE A SELECT WITH "WHERE CLAUSE" THE CONSTRAINT PK IS USED, BUT I WANT TO USE PK INDEX THAT IS WITH INVERSE ORDER(DESCENDING) AND I'M NOT GETTING IT.


Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2002-03-26 : 10:03:05
If the SELECT doesn't have an ORDER BY, it doesn't have a defined order. You need to explicitly tell it to order rows in the result.

SELECT *
FROM my_table
ORDER BY pk_column DESC


Go to Top of Page
   

- Advertisement -