It's documented change in the SQL Engine behavior: ORDER BY clause cannot include field that it's not in the field list if DISTINCT is used. You can add OrderMain to the field list.
SELECT DISTINCT Numero, OrderMain FROM Temp ORDER BY OrderMain INTO CURSOR Temp2
>The following doesn't work anymore in VFP 9:
>
>
>SELECT *,Numero AS OrderMain FROM Message INTO CURSOR Temp READWRITE
>INDEX ON STR(Numero)+STR(Ordermain) TAG OrderMain
>SELECT DISTINCT Numero FROM Temp ORDER BY OrderMain INTO CURSOR Temp2
>
>
>It says SQL: ORDER BY clause is invalid
>
>I am trying to localize the problem and I also need to find a workaround. If someone has an answer right away, that would be appreciated.
--sb--