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.
| 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 arematname code verifiedadtexxxx E 05/03/2004cxcxz S 04/03/2004Suppose 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 blahFrom blahIf @@rowcount = 0Begin print 'Hallo'End -JonJust a starting member. |
 |
|
|
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 |
 |
|
|
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.-JonJust a starting member. |
 |
|
|
|
|
|