Microsoft KB Archive/136421

= How NULL Values Sort in Indexes =

Article ID: 136421

Article Last Modified on 2/15/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q136421



SUMMARY
Expression indexes that evaluate to NULL are inserted into the .cdx file before non-NULL entries, so NULL expressions in indexes sort at the beginning rather than at the end.



Steps to Reproduce Behavior
 Create a program called Myprog.prg.  Key in the following code fragment: CREATE TABLE mytable (lastname c(20) NULL, firstname c(20) NULL, ;     city c(20) NULL) INSERT INTO mytable (lastname,firstname,city) ; VALUES ("Ansarti","Jim","San Jose") INSERT INTO mytable (lastname,firstname,city) ; VALUES ("Hayden","Rance",.NULL.) INSERT INTO mytable (lastname,firstname,city) ; VALUES ("Putnam","Phil","New Orleans") USE mytable INDEX ON city TAG city         && Create the Index and the Tag SET ORDER TO city              && Set the order to the Tag BROWSE  Save the program.  In the Command window, type: DO Myprog.prg  When the program runs, it displays a Browse window where the first record containing .NULL. in the city field is the first field in the Browse window.

