• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

question about iff

Hello,

I try select distinct d.LegalName, IIF ( (et.Description = 'VA'), 'YES', 'NO' )  as 'WITHOUT VA', a.* from ##CPTE a

The following error is returned :
Incorrect syntax near '='.

How can I resolve it?

Thanks
0
bibi92
Asked:
bibi92
  • 2
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
SQL Server doesn't do IIF, it does CASE.

SELECT DISTINCT
   d.LegalName,
   CASE WHEN et.Description = 'VA' THEN 'Yes' ELSE 'NO' END as Without_VA,
-- the rest goes here

For more info on CASE blocks there's an article out there on SQL Server CASE Solutions if that helps.
0
 
bibi92Author Commented:
Thanks
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now