Quantcast
Channel: SCN: Message List - SAP Adaptive Server Enterprise (SAP ASE) for Custom Applications
Viewing all articles
Browse latest Browse all 3587

Re: not null or not exists for ase 12.5

$
0
0

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

============


Viewing all articles
Browse latest Browse all 3587

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>