SQL Server 2008 R2 – How to Use the Decode Function

sql-server-2008-r2

Can some one help me to figure out the equivalent function to decode in SQL Server.

Here is the statement which I used for Oracle and I want it for SQL Server. I tried but not able to get it.

UPDATE [SCHEMA].TLS_FAC_PRC_ONG 
SET FPO_RID_OWNER = decode(FPO_RID_OUTSTANDNG,'NONE',FPO_PID_FACILITY,NULL,FPO_PID_FACILITY,FPO_RID_OUTSTANDNG),
FPO_CDE_OWNER = decode(FPO_RID_OUTSTANDNG,'NONE','FAC',NULL,'FAC','OST');

Best Answer

UPDATE [SCHEMA].TLS_FAC_PRC_ONG
SET FPO_RID_OWNER = 
CASE WHEN FPO_RID_OUTSTANDNG='NONE' THEN FPO_PID_FACILITY
WHEN FPO_RID_OUTSTANDNG IS NULL THEN FPO_PID_FACILITY
ELSE FPO_RID_OUTSTANDNG END,
FPO_CDE_OWNER = 
CASE WHEN FPO_RID_OUTSTANDNG='NONE' THEN 'FAC'
WHEN FPO_RID_OUTSTANDNG IS NULL THEN 'FAC'
ELSE 'OST' END

DECODE function is a shortcut? for CASE