Is there any way in a simple query to return a Boolean value using an SQL EXISTS statement without using a WHERE clause?
All of the 2008 R2 SQL Server Books Online examples show another WHERE clause and two tables. Website examples show either a WHERE or an IF-THEN-ELSE in a procedure.
I was hoping to do the following on one table:
EXISTS
(SELECT cx.id
FROM fdd.admissions_view as cx
WHERE cx.id=1111 and cx.campus='MEXI')
The SELECT statement works fine and returns the ID. I just want to add EXISTS to return a BOOLEAN, but the syntax above is not valid.
Can I do something like this? If so, what am I missing syntax-wise? If not, what other technique may work?
Please advise. Thanks.
How about something like
select case when count(cx.id) > 0 then 1 else 0 end
FROM fdd.admissions_view as cx
WHERE cx.id=1111 and cx.campus='MEXI'
?