catch empty list using SQL query

ar_pad

Active member
Joined
Jun 5, 2006
Messages
26
Programming Experience
Beginner
Hi,
I'm trying check the records which satisfies the following condn.
select @p1 = su1 from RER where (no=10 and atp ='N')
It returns empty list . bcos no match found.that's ok.
But i need to write the logic if record is not there.
i tried to do as follows
if ((@p1 =null) or (p1=' '))
...some logic
else
.. other logic
It's always executing else case. How do i catch empty value using sql query.
Is there any command there like null?
I tried in SQL query analyzer. Using SQL 2000.
Thank You.
 
VB.NET:
IF EXISTS(select su1 from RER where (no=10 and atp ='N'))
  BEGIN
    select @p1 = su1 from RER where (no=10 and atp ='N')
  END
ELSE
  BEGIN
    -- do what you need to do for the else
  END

-tg
 
Back
Top