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?  
WonderwallAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AliSyedCommented:
Idonot understandyour question.
WonderwallAuthor Commented:
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,
appariCommented:
try

if @@rowcount = 0 -- no rows returned from the previous sql
if @@rowcount <> 0 -- row count  returned from the previous sql

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WonderwallAuthor Commented:
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?
appariCommented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.