Your correct Philip. If your performing the SQL statement in Foxpro then the CASE statement will not work. Thanks for catching my assumption.
Just goes to show you how "one-tracked" someone can be.<grin>
>Jeffrey,
>
>If you are using SQL Server, then Stephen's solution will work. But, I don't believe that the Fox driver supports CASE in SQL statements. You can use a union, but remember that fields must be the same size, thus add SPACE(33) to the first errmsg so that it will be the same size as the second. There can only be one order by clause, and it must numerically refer to a column.
>
>
>SELECT TEMPALIAS.*,
> MF_158.DATE_IN AS IMPORTED,
> 'Record already imported.'+SPACE(33) AS Errmsg
> FROM TEMPALIAS, MF_158
> WHERE ALLT(TEMPALIAS.UNIQKEYSAS) = ALLT(MF_158.UNIQKEYSAS)
> UNION
>SELECT TEMPALIAS.*,
> MF_158.DATE_IN AS IMPORTED,
> 'Records previously found as errors but have passed since.' AS Errmsg
> FROM TEMPALIAS, PROB_158, MF_158
> WHERE ALLT(TEMPALIAS.UNIQKEYSAS) = ALLT(PROB_158.UNIQKEYSAS)
>INTO CURSOR INPR158
> ORDER BY 1 ???
>
>
>..., or something like that.
>
>Hope this helps,
>
>Phil