On Thursday 13 November 2003 12:25, Graham wrote:
> Apologies as this probably isn't really for this list but...
>
> In postgresql you can execute a statement such as:
>
> SELECT 1 > 2;
>
> And it would return 'f'
>
> Does anyone know if you can do this in SQL Server as I have to do a
> conversion of some prewritten SQL code.
If you look here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_oa-oz_3qpf.asp
"Unlike other SQL Server data types, a Boolean data type cannot be specified
as the data type of a table column or variable, and cannot be returned in a
result set."
Generally you'd use a BIT type instead of a boolean, but that's not going to
help you here. I'm not even sure if you can use a boolean expression in the
column-list part of a select.
The only thing I can think of is to use a case: SELECT WHEN 1>2 THEN 1 ELSE 0 END;
As to why MSSQL doesn't support booleans, you could try asking their tech
support, but I wouldn't get your hopes up.
-- Richard Huxton Archonet Ltd