From: RG on
When writing an a business application where speed is important, are there
isssues with using case expression in sql queries? and why?

Thanks in advance
From: Eric Isaacs on
The short answer is Yes. Any function or CASE statement you use in
SQL to convert or cast or modify the results from what is stored in
the database affects the performance of the query. It's better to do
these conversions outside of the scope of the database, whenever
feasible. Using a CASE statement isn't as much of an issue for small
result sets, but it can be a significant issue when a case expression
is involved in a JOIN or a WHERE clause, as well as when it's used to
convert data in large result sets.

-Eric Isaacs
From: Erland Sommarskog on
RG (RG(a)discussions.microsoft.com) writes:
> When writing an a business application where speed is important, are there
> isssues with using case expression in sql queries? and why?

Depends on how you use them. If it's just an expression in a SELECT
list, there is not likely to be much harm. If you put it in a WHERE
clause, you may preclude the use of an index. But again that depends
on how you use it.

The question is too broad to warrant any detailed answer.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx