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 |
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-10-06 : 08:42:39
|
| Hi,Trying to write a stored proc with an If statement.Trying to do the following:If count(@param) > 1THEN'Select....'ELSE'Select.....'But getting just simple error, syntax wrong near Then AND ElseJust trying to count the number of entries in the parameter, as its a multi value select parameter.Any ideas? thanks |
|
|
Kabila
Starting Member
33 Posts |
Posted - 2009-10-06 : 08:47:00
|
| If len(@param) > 1THEN'Select....'ELSE'Select.....' |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-06 : 08:47:58
|
| If len(@param)-LEN(replace(@param,',',''))+1 > 1'Select....'ELSE'Select.....'MadhivananFailing to plan is Planning to fail |
 |
|
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-10-06 : 08:59:05
|
Would it work same wayIf (select len(Region) from table where (country in (@country)) > 1 quote: Originally posted by madhivanan If len(@param)-LEN(replace(@param,',',''))+1 > 1'Select....'ELSE'Select.....'MadhivananFailing to plan is Planning to fail
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-06 : 09:41:16
|
quote: Originally posted by cipriani1984 Would it work same wayIf (select len(Region) from table where (country in (@country)) > 1 quote: Originally posted by madhivanan If len(@param)-LEN(replace(@param,',',''))+1 > 1'Select....'ELSE'Select.....'MadhivananFailing to plan is Planning to fail
NoMadhivananFailing to plan is Planning to fail |
 |
|
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-10-06 : 09:45:00
|
it worked as:If (select count(Region) from table where (country in (@country)) > 1 quote: Originally posted by madhivanan
quote: Originally posted by cipriani1984 Would it work same wayIf (select len(Region) from table where (country in (@country)) > 1 quote: Originally posted by madhivanan If len(@param)-LEN(replace(@param,',',''))+1 > 1'Select....'ELSE'Select.....'MadhivananFailing to plan is Planning to fail
NoMadhivananFailing to plan is Planning to fail
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-07 : 02:14:45
|
| Does @country have comma seperated values?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|