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 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2006-06-05 : 06:09:49
|
| within my stored procedure how can i run an sql statement (like select name from names where name is like @myname + %) and if there are no records do select @valid=0I basically want to know how I can check if the sql returns no recorsdsthansk |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-06-05 : 06:16:43
|
select @@rowcount after the statement gives you that informationGo with the flow & have fun! Else fight the flow Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-05 : 06:17:25
|
use @@rowcount. Place it immediately after your select statement.select name from names where name is like @myname + %if @@rowcount = 0 select @valid = 0else select @valid = 1 KH |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-06-05 : 06:18:43
|
 KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-05 : 07:11:56
|
| If you use front end application, then make use of recordset's eof If rs.eof=true then--no recordsend ifMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|