October 8, 2008 at 1:09 pm
Is there a limit on the number of WHEN statements I can use in CASE clause of SQL2005.
CASE Test
When 'Q' then ...
When 'W' then ...
.
.
.and so on.:w00t:
Do we have a limit on how many WHEN we can include in one CASE statement.
October 9, 2008 at 7:40 am
I'm not aware of any limit other than readability and practicality. I think the most I have had is 4 or 5 and, IMHO, once you start getting beyond that you need to re-assess the query and maybe even the design.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
October 9, 2008 at 7:50 am
Thanks Jack!!!
Actually I need to build a dynamic query where number of WHERE statements in CASE will depend upon number of records in a given table.Do having a large number of WHERE statement deteriorates the performance?
October 9, 2008 at 7:59 am
Adding conditions to a WHERE clause can help or hinder performance. It all depends on indexing and selectivity. If you are using indexed columns then performance should be fine.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply