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 |
|
norty911
Starting Member
41 Posts |
Posted - 2007-10-24 : 09:46:22
|
| Hey guys,What would be a better / more elegant solution to something likeIF(@areaCode = '111' OR @areaCode = '222' 0R @areaCode = '333')BEGIN //do somethingENDthat uses less OR's in an IF statement? |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-10-24 : 09:49:22
|
| if (@areaCode in ('111', '222', '333'))_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-24 : 09:49:44
|
IF @AreaCode IN ('111', '222', '333') E 12°55'05.25"N 56°04'39.16" |
 |
|
|
norty911
Starting Member
41 Posts |
Posted - 2007-10-24 : 09:50:52
|
| Muchly appreciated |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-24 : 09:53:19
|
Ouch me E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-24 : 10:00:11
|
Note that IN is short form of multiple ORs MadhivananFailing to plan is Planning to fail |
 |
|
|
KenW
Constraint Violating Yak Guru
391 Posts |
Posted - 2007-10-24 : 15:42:18
|
quote: Originally posted by Peso Ouch me
Ouch! And only 22 seconds, too. :-) |
 |
|
|
|
|
|