Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Good Morning,I've just started working with CASE statements and have found them extremely useful so far. However I've come accross a bit of an issue trying to put OR into one, see belowCASE WHEN dbo.Agent.AgentName = 'Abacus (Amalgamated)' OR 'Alan Blunden & Co Limited (Spectrum Abacus)' THEN 'ABACUS' ELSE AgentName ENDI get the unable to parse expression error from this. It works if i just use one name but goes wrong as soon as i include the OR.does anyone know what i'm doing wrong?Thanks very much Rob
RickD
Slow But Sure Yak Herding Master
3608 Posts
Posted - 2011-09-19 : 04:38:56
Either:
CASE WHEN dbo.Agent.AgentName IN ('Abacus (Amalgamated)','Alan Blunden & Co Limited (Spectrum Abacus)') THEN 'ABACUS' ELSE AgentName END
or:
CASE WHEN dbo.Agent.AgentName = 'Abacus (Amalgamated)' OR dbo.Agent.AgentName = 'Alan Blunden & Co Limited (Spectrum Abacus)' THEN 'ABACUS' ELSE AgentName END