issue with case statement

Posted on 2009-12-16
Last Modified: 2012-05-08
I have this code and am getting an error, can someone help me understandy why the error exists with both case statements but not individually?

select *,
CASE WHEN ([Planned_Event_Status] = 'ES' AND [Activity Stat Cd] = 'A') THEN 'Y'
CASE WHEN ((NOT ([Planned_Event_Status] LIKE 'ES')) AND [Activity Stat Cd] = 'O') THEN 'Y'
ELSE 'N' END AS [(GPSy - PLC Error)]



Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'CASE'.
Question by:Fairfield
    LVL 142

    Accepted Solution

    remove the second CASE. you only need CASE once in the beginning, from there, you repeat only the WHEN keyword

    Author Closing Comment

    Duh.....go figure

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    729 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