Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Conditional Statement in View Design

Author  Topic 

glilley
Starting Member

10 Posts

Posted - 2008-04-10 : 12:05:59
Have a View where I need to enter a conditional IF_THEN_ELSE statement in a new field (field has an alias). If this were an Access query I would do following:

IIf([dbo.AR1_CustomerMaster.EmailAddress] Is Null, "A", "B")

How can I accomplish same in View design??

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-10 : 12:07:05
Use CASE expression.

Case when col is null then 'A' else 'B' end


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2008-04-10 : 12:48:48
Brilliant!!

So you don't really care about the original values in the column?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -