Hi,
I’ve got an update like this one:
UPDATE PROCESSOS
SET
CDU_TIPOSERVICO =
CASE
WHEN CDU_TIPOSERVICO = 'CSS'THEN CDU_TIPOSERVICO
WHEN CDU_TIPOSERVICO = 'USP'THEN ‘FFF’
WHEN CDU_TIPOSERVICO = 'PES'
ELSE ‘XXX’
END
On the first “when” if the variable is equal to ‘CSS’ I want to do nothing, I mean I want the variable to keep its value, how can I achieve that ?
Should I do -> WHEN CDU_TIPOSERVICO = 'CSS'THEN CDU_TIPOSERVICO
Or, there is another way ?
Thanks !
Your logic is perfectly correct...
Other possible solution - don't run the update statement against the 'CSS',
Code Block
update processos
set
cdu_tiposervico =
case
when cdu_tiposervico = 'USP' then 'fff'
when cdu_tiposervico = 'PES' then 'some value'
else ‘xxx’
end
where
isnull(cdu_tiposervico,'') <> 'CSS'
|||
Hi.
Thanks for your reply.
I didn't understood this part - isnull(cdu_tiposervico,'') <> 'CSS'
why not just where cdu_tiposervico <>'CSS'
What the functionality of the second parameter in the function isnull ?
|||If there is any null value on "cdu_tiposervico" then the corresponding "cdu_tiposervico" will be updated with 'XXX'.
If you reomove isnull the null value will be retained as NULL.
No comments:
Post a Comment