Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Must use a CASE to return true/false from an expression?
Message
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01102115
Message ID:
01102119
Views:
13
This message has been marked as the solution to the initial question of the thread.
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 may 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)?
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform