Solved

question about iff

Posted on 2014-03-12
3
186 Views
Last Modified: 2014-03-13
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
Comment
Question by:bibi92
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 39924910
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
 

Author Closing Comment

by:bibi92
ID: 39925687
Thanks
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39926123
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now