Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set order

Status
Not open for further replies.

paul1941

Programmer
May 25, 2006
32
BE
Hello All

I have a table with 3 fields: firstname c (50), lastname c (50) and birthdate d(8)
I want to order the table first on birthdate, then on lastname and then on firstname.
How to manage it correctly?

Regards, Paul
 
Code:
INDEX ON DTOS(birthdate)+UPPER(lastname)+UPPER(firstname) TAG ...

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
hello Paul,

Another possiblity is :
index on dtoc(birthdate,1) ascending or descending +alltrim(upper(lastname)) + alltrim(upper(firstname)) tag ...


FILIP MERLIER
 

It's not a good idea to build an index based on ALLTRIM(), or on any variable length expression.

From VFP Help:
Code:
If you attempt to build an index with a key that varies in length, the key will be padded with spaces. Variable-length index keys aren't supported in Visual FoxPro.

In some cases it could potentially create problems.
If you are worried that Lastname or Firstname field can start with a space, you should LTRIM() the space and then PADR() the value again to some fixed length.

But the best thing is to maintain the table without the leading spaces and to use the whole Lastname and Firstname in the index key.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top