Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Case Statement in Update Script

Author  Topic 

bholmstrom
Yak Posting Veteran

76 Posts

Posted - 2013-12-31 : 10:06:17
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


Bryan Holmstrom

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-31 : 10:23:46
The code doesnt have any obvious issues other than a typo ie you've used } instead of ]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

bholmstrom
Yak Posting Veteran

76 Posts

Posted - 2013-12-31 : 10:30:01
Wow that was my bad, thanks and have a great New Year

Bryan Holmstrom
Go to Top of Page
   

- Advertisement -