What is the equivalent of the IIF command in SQL Server

–In MS Access you would use :-

Select iif(field>10,”large”, “small”) as Size from Table

–With SQL Server, use the CASE command

SELECT Size =
CASE
WHEN field > 10 THEN “large”
ELSE “small”
END
from Table

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s