several possible solutions. Here is one:
1> select isnull(sum(1),0) where exists (select 1 from sysobjects)
2> select isnull(sum(1),0) where not exists (select 1 from sysobjects)
3> go
-----------
1
(1 row affected)
-----------
0
(1 row affected)
Here is another (more complicated) way:
1> select 1
2> where exists (select 1 from sysobjects)
3> union all
4> select 0
5> where not exists (select 1 from sysobjects)
6>
7> select 1
8> where exists (select 1 from sysobjects where 1=2)
9> union all
10> select 0
11> where not exists (select 1 from sysobjects where 1=2)
12> go
-----------
1
(1 row affected)
-----------
0
(1 row affected)
Here is another (slower) way:
1> select sign(count(*)) from sysobjects
2> select sign(count(*)) from sysobjects where 1=2
3> go
-----------
1
(1 row affected)
-----------
0
(1 row affected)
============
Edit:
Just saw Mark's code, and I like that much better than my suggestions
============