dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL
Expertise: Beginner
Apr 17, 2019

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Working with the IIF Statement in T-SQL

You can use the IIF statement to check quickly for conditions. For example:

DECLARE @Spy varchar(20) = '07'
 
SELECT IIF(@Spy = '007', 'Bond, James Bond', 'Ernst Stavro Blofeld')

If the Spy Variable is 007, then it will return "Bond, James Bond." If it is anything else, it will return the second part of the statement, which is: "Ernst Stavro Blofeld"

Hannes du Preez
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date