Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Must use a CASE to return true/false from an expression?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01102115
Message ID:
01102121
Vues:
16
Thanks, I thought that the expression would resolve to 1/0 since it is used in the database for true/false, but they are seperate.


>SQL Server doesn't have a logical data type. If you're refering to the bit data type than it's a numeric data type in which 1/0 represent true/false respectivelly. SQL Serve doesn't support convertion of true/false exppression into numeric data type or vise versa. You have to use CASE function to do that.
>
>>In one of my VFP queries, I have an expresion in a SQL Select that evaluates to true/false based on the comparison of a date to today.
>>
>>(Date() <= device.warrdate) as warranty
>>
>> What true if the warranty is still active, in otherwords if today is less than the warranty end date.
>>
>>In switching this SQL statement to pull from SQL Server, I get an syntax error when I convert the statement to:
>>
>>(Date() <= device.warrdate) as warranty
>>
>>instead I could only get it to work using an inline condition case statement
>>
>>CASE WHEN datediff(dd,getdate(), device.warrdate) >= 0 THEN 1 ELSE 0 END
>>
>>Is it not possible with T-SQL in SQL Server 2005, to have an expression evaluate to true/false (really 1/0)?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform