SQL-query with ADO.NET

  • Thread starter Thread starter Mika M
  • Start date Start date
M

Mika M

How to do something like IIf with Sql-query using Sql-Server 2000?

I mean my database table has bit(boolean) field, and if this bit field is on
(true) then calculation field should use other formula than when this
bit-field is not on (false) like ...

IIF(MyTable.BitField = true, "FieldA + FieldB", "FieldA + FieldC") AS
SumValue

I think this should be easy, but I haven't succeeded yet. Yes, I know this
is not Sql-query question, but I need this query with ADO.NET :)
 
Sorry my writing error! Last text line should be ...

Yes, I know this is not Sql-query NG, but I need this query with ADO.NET :)
 
Hi Mika,

Straight from the sql server help files (CASE statament):
SELECT 'Price Category' =
CASE
WHEN price IS NULL THEN 'Not yet priced'
WHEN price < 10 THEN 'Very Reasonable Title'
WHEN price >= 10 and price < 20 THEN 'Coffee Table Title'
ELSE 'Expensive book!'
END,
CAST(title AS varchar(20)) AS 'Shortened Title'
FROM titles
ORDER BY price
 
Back
Top