June 17, 2011 at 8:44 am
Hi everyone,
Few of the queries that I'm watching now have 15-20 case expressions. Just curious if case is resource intensive and if there's an alternative approach.
Thank you.
June 20, 2011 at 1:20 am
It depends , case allows for conditional logic based on the data within the returned result set and therefore can make some queries really simple to code and effective. The usage will depend on the logic within which it is used. A possible alternative to the case statement would be Join to a table which contains the lookup value and the alternative. but this approach would not work for a majority of cases such as performing calculations etc.
June 20, 2011 at 2:35 pm
I recently ran into this issue: "SQL Server allows for only 10 levels of nesting in CASE expressions" (http://msdn.microsoft.com/en-us/library/ms181765.aspx).
I've only had issues with this in scripts that run across linked servers but something to keep in mind.
_____________________________________________________________________
- Nate
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply