Question : sql query with case

I have the following query:

SELECT  ID, Case dbo.sf_ReturnFolderCount(Bids.BidID, @companyID) When 0 then '<BR>' END from table.

But i want <BR> to show when the result returned from the fucntion dbo.sf_ReturnFolderCount is > 0.  If I add a > in front of the 0 i get a error.

Answer : sql query with case

SQL Server supports 2 types of Case statements;

CASE <expression>
WHEN <x> then <y>
WHEN <z> then <a>
...
END

This one is useful if you can easily slot <expression> into singular value buckets.
The other one is

CASE
WHEN <expression1> then <y>
WHEN <expression2> then <a>
...
END

Where each <expression> is fully evaluated again and again.  Obviously if you are calling a function and it can return one of 10 values, it would not be advisable to use the 2nd form since it may call the function 10 times to get to the last branch.
Random Solutions  
 
programming4us programming4us