#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Philadephia
    Posts
    16
    Rep Power
    0

    Case Statement in Update Script


    Good morning and Happy New Year,

    I am trying to do an update on a table where one of the update set statment needs to based on the "state' of another field.

    If the field nc_opp_status already equals 'Approved' then I do NOT want to update the nc_modifydate field, otherwise take the incoming paramenter and update the field nc_modifydate.

    I am getting the following error:

    An expression of non-boolean type specified in a context where a condition is expected, near 'ELSE'

    Here is the statment:

    SET NOCOUNT ON;
    UPDATE [NCOS].[dbo].[NCOS_Data]
    SET [NC_SP_ID] = @nc_sp_id
    ,[NC_Opportunity_CRMID] = @nc_opportunity_crm_id
    ,[NC_ModifyDate] =
    CASE
    WHEN [NC_Opp_Status} = 'Approved' THEN [NC_ModifyDate]
    ELSE @nc_modifyDate
    END

    Any helps is of course always appreciated.

    Thanks
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    [NC_Opp_Status}
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo