Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Boolean values

Author  Topic 

Utpal
Posting Yak Master

179 Posts

Posted - 2002-03-03 : 00:25:53
Hi everybody,

How are the boolean values of "True" and "False" represented in SQL and T-SQL syntax ?


Nazim
A custom title

1408 Posts

Posted - 2002-03-03 : 00:46:06
with 1(True) and 0(false) mostly.

eg : isnumeric() will return 1 if it is true or else returns 0 if it is false

if isnumeric('23')=1

HTH

--------------------------------------------------------------


Edited by - Nazim on 03/03/2002 08:45:17
Go to Top of Page

samrat
Yak Posting Veteran

94 Posts

Posted - 2002-03-03 : 01:01:28
True is evaluated as 1 and False as 0. and they are stored in BIT datatype

Cheers,

Samrat
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2002-03-03 : 08:40:34
In contrast to Access, for example, the outcome of a boolean expression cannot be stored directly (or returned from a query) in SQL Server. SQL Server's bit type is not freely convertable with booleans. For example, where in Access you might say
SELECT (column=3) FROM tbl
In SQL Server, this would have to be expressed as something like
SELECT CASE WHEN column=3 THEN 1 ELSE 0 END FROM tbl


Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2002-03-03 : 17:09:02
quote:

How are the boolean values of "True" and "False" represented in SQL and T-SQL syntax ?



Badly!

DavidM

Tomorrow is the same day as Today was the day before.
Go to Top of Page

Utpal
Posting Yak Master

179 Posts

Posted - 2002-03-04 : 05:40:24
Thanks to all of you !

Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2002-03-25 : 12:07:51
>> How are the boolean values of "True" and "False" represented in SQL and T-SQL syntax? <<

Boolean datatypes do not exist in Standard SQL-92. You should not be trying to program with them. If thre was such a thing, then it would have to take the values TRUE, FALSE, and UNKNOWN; but also be NULL-able. Suddenly we are into four values logic!!



--CELKO--
Joe Celko, SQL Guru
Go to Top of Page
   

- Advertisement -