Problems with Update...Case Statement (1 Viewer)

GrahamK

Registered User.
Local time
Today, 14:30
Joined
Aug 5, 2008
Messages
25
Hello All,

I'm trying to run the query Below on SQL Server 2000 and and getting the error "Line 4: Incorrect syntax near '=' " I wonder if anyone can offer assistance?

Code:
UPDATE tblStaffQual
SET Status = 
     (CASE
        WHEN GETDATE() >= Expires_Date THEN Status = 'Expired'
        WHEN GETDATE() < (Expires_Date-90) THEN Status = 'Current'
        ELSE (Status = 'Approaching')
        END
    );

Many Thanks
Graham
 
Last edited:

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:30
Joined
Aug 30, 2003
Messages
36,139
For starters, this is the kind of thing that should not be stored, rather calculated on the fly as needed. You would have to run this every day to keep things current. That said, the syntax would be:

WHEN GETDATE() >= Expires_Date THEN 'Expired'
 

GrahamK

Registered User.
Local time
Today, 14:30
Joined
Aug 5, 2008
Messages
25
For starters, this is the kind of thing that should not be stored, rather calculated on the fly as needed. You would have to run this every day to keep things current. That said, the syntax would be:

WHEN GETDATE() >= Expires_Date THEN 'Expired'

Paul,

Thank you very much for your assistance!

Graham
 

Users who are viewing this thread

Top Bottom