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 |
|
CrazyT
Yak Posting Veteran
73 Posts |
Posted - 2010-04-23 : 12:13:20
|
| how would i write an if clause in a stored procedureif (select count(*) from table) > 1 then beginreturn countendelsebeginreturn 0end |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-23 : 12:18:57
|
Maybe this:declare @cnt intselect @cnt= count(*) from Tableif @cnt>1begin select @cnt as resultendelsebegin select 0 as resultend No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
sanjnep
Posting Yak Master
191 Posts |
Posted - 2010-04-23 : 12:27:23
|
| dude you can do like this but you can't use return here coz you are not using function. balle balle if exists(select a.cnt from (select count(*) as cnt from sysobjects) a where a.cnt > 1)beginselect count(*) from sysobjectsendelseprint(0) |
 |
|
|
CrazyT
Yak Posting Veteran
73 Posts |
Posted - 2010-04-23 : 13:16:43
|
| thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-04-26 : 04:09:41
|
| why dont you use just this?declare @cnt intselect @cnt= count(*) from Tableselect @cnt as resultMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|