SQL Error using CASE statement


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: SQL Error using CASE statement

  1. #1
    Ted Young Guest

    SQL Error using CASE statement


    I am trying to run the SQL below and I am getting an error that states:

    INCORRECT SYNTAX NEAR '>'

    Does anyone have any ideas on what could be wrong?

    UPDATE tblAgentStatusHistory
    SET EffectiveDate =
    CASE EffectiveDate
    WHEN EffectiveDate > '12/1/1997' THEN '06/28/1968'
    ELSE '06/28/2001'
    END
    WHERE AgentID = '000528612'

    Thanks!

    Ted

  2. #2
    DaveSatz Guest

    Re: SQL Error using CASE statement

    try:
    UPDATE tblAgentStatusHistory
    SET EffectiveDate = (
    CASE
    WHEN EffectiveDate > '12/1/1997' THEN '06/28/1968'
    ELSE '06/28/2001'
    END )
    WHERE AgentID = '000528612'
    --
    HTH,
    David Satz
    Principal Software Engineer
    Hyperion Solutions
    ->Using SQL Server 7.0 SP3/6.5 SP5a/Cold Fusion 4.5.1 SP2/VSS
    (Please reply to group only - emails answered rarely)
    -----------------------------------------------------------------

    "Ted Young" <tedyoung@connecticare.com> wrote in message
    news:3b584394$1@news.devx.com...
    >
    > I am trying to run the SQL below and I am getting an error that states:
    >
    > INCORRECT SYNTAX NEAR '>'
    >
    > Does anyone have any ideas on what could be wrong?
    >
    > UPDATE tblAgentStatusHistory
    > SET EffectiveDate =
    > CASE EffectiveDate
    > WHEN EffectiveDate > '12/1/1997' THEN '06/28/1968'
    > ELSE '06/28/2001'
    > END
    > WHERE AgentID = '000528612'
    >
    > Thanks!
    >
    > Ted




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center