Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the switch statement in a query

Status
Not open for further replies.

sk8er1

Programmer
Jan 2, 2005
229
US
I just used a switch statement in a query. Its really powerful feature. Its better than stringing along an IIF statement. What do you guys think?
 
I think if used properly a switch function will work well in place of a lengthy IIF function. I have also used choose as well but generally I find I have to use these in places where a database is not well designed. A join on a properly indexed table is faster then having to evaluate each possible expression.

Switch evaluates all of the expressions, even though it returns only one of them. For this reason, you should watch for undesirable side effects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top