Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 RowCount

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-05-24 : 10:29:18
Babita writes "My question is first i am selecting lastday of a month .
I have a table like verification whose cols are
matname code verifiedadte
xxxx E 05/03/2004
cxcxz S 04/03/2004
Suppose i am selecting those records where code is not 'E' or 'S'
After that when i write sql%rowcount that will return 1.
I want to display "Hallo" if nothing is selected how will i do that one."

surefooted
Posting Yak Master

188 Posts

Posted - 2004-05-24 : 13:59:01
Immediately after the select statement trap the system variable @@rowcount by assigning it to a variable or using it right there. If you choose not to assign it to a variable, remember it will change on the very next statement. If you do assign it, you can use it later.

Select blah
From blah

If @@rowcount = 0
Begin
print 'Hallo'
End


-Jon
Just a starting member.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-05-24 : 14:23:55
It may be that you don't need @@rowcount at all.

You could do:
if not exists(Select blah from blah)
Begin
print 'hallo'
End
Go to Top of Page

surefooted
Posting Yak Master

188 Posts

Posted - 2004-05-24 : 14:39:42
yep, that works too. Clean and simple if you don't need to know what the rowcount was.

-Jon
Just a starting member.
Go to Top of Page
   

- Advertisement -