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 2008 Forums
 Transact-SQL (2008)
 select query get reult as true or false boolean

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-07-21 : 10:41:42
How can i get by executing the following to see ressult as true or false(boolean value)

when i execute this query, i a row is returned that means true other wise false.

select Top1 DocumentID from TAB_ccsNetDMRevision where RevID=@revID

Thank you very much for the helpful info.

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-07-21 : 11:32:32
IF EXISTS (select 1 DocumentID from TAB_ccsNetDMRevision where RevID=@revID)
SELECT 1
ELSE
SELECT 0

--------------------------
http://connectsql.com/
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2011-07-22 : 11:43:34
SQL does not have a BOOLEAN data type for a column in your record set. As lionofdezert has rightly shown, the best you can do is approximate it. The BIT data type is the closest but it is a numeric value; not a BOOLEAN.

=======================================
I have never met a man so ignorant that I couldn't learn something from him. -Galileo Galilei, physicist and astronomer (1564-1642)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-22 : 11:46:41
in the above case it would be returned as a integer value. for making it boolean you need to explicitly cast it to bit.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -