TSQL to return NO or YES instead TRUE or FALSE
56,869
Solution 1
If varchar or bit, handling NULLs
case
when BASIC = 'FALSE' then 'NO'
when BASIC <> 'FALSE' then 'YES'
else 'UNDEFINED'
end
or if just bit
case
when BASIC = 1 then 'YES'
when BASIC = 0 then 'NO'
else 'UNDEFINED'
end
Edit:
SELECT
TipoImovel_Id AS TII_SEQ,
Descricao AS TII_DSC,
Sigla AS TII_DSC_SIGLA,
-- choose which one you want from the answers here
case
when BASIC = 1 then 'YES'
when BASIC = 0 then 'NO'
else 'UNDEFINED'
end AS SomeColumnName
FROM San_TipoImovel";
Solution 2
since SQL 2012 you can use IIF function
IIF(BASIC = 'TRUE', 'YES', 'NO')
Solution 3
case when column = 'FALSE' then 'NO' else 'YES' end
Comments
-
Lucas_Santos almost 2 years
How can I show a different value if some columns return FALSE,
for example,
COLUMN "BASIC" returns FALSE, but I need show for the user YES or NO. Case FALSE, return NO.