Link to home
Start Free TrialLog in
Avatar of Wonderwall
Wonderwall

asked on

sql server return value on select

Aloha, I am trying to get the value in a select statement if no rows are returned. I have tried using the @@error message but it always returns 0. Should it be +100 if no rows are found?  
Avatar of AliSyed
AliSyed
Flag of United States of America image

Idonot understandyour question.
Avatar of Wonderwall
Wonderwall

ASKER

I have a stroed procedure and I am trying to figure out based on a value from the select whether any rows were pulled.

I have used if @@rowcount < 1 and if @@error <> 0 but the sql statement always return 0 as the value even if it found no rows. Shouldn't it pull state 100 if no rows found.  mahalo,
ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I found a work around but I think the issue was that I had a subquery in the where clause and while that evaluted to 0 the outer still returned 1. any thoughts?
not sure what your problem is, @@rowcount will return the number of rows affected/returned by the last SQL executed. returns 0 if no rows are affected.