Solved

question about iff

Posted on 2014-03-12
3
190 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DTS Connection Failed 7 70
Need help how to find where my error is in UFD 6 29
Query group by data in SQL Server - cursor? 3 33
SQL Function NOT ROUND 9 10
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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…

773 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