Brenda,
A string comparison works differently in SQL commands and in the rest of FoxPro. See SET EXACT and SET ANSI for details. With both those settings OFF, "" <> "04" is true in the command window and false in the query. It's better to avoid ALLTRIM() function in the queries WHERE clause. I don't see why do you need ALLTRIM() and UPPER() in this case at all.
Select * FROM property WHERE key = '00011987' and;
prop_type != '04'
>
>The following SQL returns an empty result set. The prop_type is two spaces. When I am in the command window, both of the SQL Where clauses return .T. when the property record pointer is on the 00011987 key. but when I run the SQL an empty result set is returned. Why?
>
>
Select * FROM property WHERE key = '00011987' and;
>alltrim(upper(prop_type)) != '04'
>
--sb--