Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Boolean value

Status
Not open for further replies.

travisbrown

Technical User
Dec 31, 2001
1,016
Is there a way to return a boolean value based on whether the rs returns any records or not?

Basically,

SELECT variableInteger
FROM (SELECT integerColumn FROM tbl)

If it finds the variable value in the array, return 'true', if not, return 'false'

Thanks kindly.

 
There is no boolean data type in Tsql.

What you can do is

Code:
if exists (select * from t) 
   select 1 -- true
else
   select 0 -- false
 
Cool. Thanks. Now to just be a pain, I have to get this to work in Access as well. Is there something similar? I don't think you can use 'EXISTS' in Access.

I can get by with this, I think. Is there a better way?

SELECT
DISTINCT
IIF(((SELECT MAX (m_i_ticket_number)
FROM tblMyIssues
WHERE m_u_userID = vUID AND m_i_ticket_number = vID)) IS NULL, 'false', 'true')
FROM tblMyIssues
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top