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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF is not recognized in a query

Status
Not open for further replies.

stsuing

Programmer
Aug 22, 2001
596
US
I have had no success including IIF expressions in any select statement that I try. I am using Sql Server 7

Here is a simple example

SELECT WkrBranchID, CltID, DayNum, IIf(WkrBranchID = 'A57', 'Baltimore','Other') as City
FROM Timecards

This statement produces this error

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '='.

Basically any function I try in the first part of the IIF statement fails.

Any advice would be greatly appreciated
 

There is no IIF in T-SQL. Try the CASE statement.

SELECT WkrBranchID, CltID, DayNum,
Case
When WkrBranchID = 'A57' Then 'Baltimore'
Else 'Other'
End as City
FROM Timecards Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
That's what I thought, but it's in the online help.

Thanks The case statement does basically the same thing.
 

IIF is in the SQL online help for Analysis Services but not for T-SQL. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top