Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iif help

Status
Not open for further replies.

OhioSteve

MIS
Joined
Mar 12, 2002
Messages
1,352
Location
US
In Access, a logical function called "iif()" exists. It follows the pattern iif(test,a,b). The test is a boolean test. If the test is true, the function returns a. Otherwise, it returns b.

The same thing exists in Excel, only its called "If()".

I tried to use this in SQL Server and got an error. What syntax should I use?
 
You can modify the following query for boolean test


if (select a from mytable ) > 10
select a
else
select b
 
You can also use CASE. Refer to the BOL, use the INDEX tab and enter CASE. Also, check out the FAQs in this forum and also do a search on CASE.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top