I am working on a code where a table has more than one Compute Column. Can we do that?
I have tried following code but It’s not working.
CREATE TABLE CRM_Doctor_Request_old(
Id int NULL,[Event_Type_Id] [bit] NULL,
Compute_Event_Type AS CASE WHEN Event_Type_Id=1 Then 'Individual' WHEN Event_Type_Id=0 Then 'Group' PERSISTED,
CRM_State_Id smallint NULL,
Compute_CRM_State AS CASE WHEN CRM_State_Id=1 Then 'Pending' WHEN CRM_State_Id=2 Then 'Approved' WHEN CRM_State_Id=3 Then 'Cancelled' PERSISTED,
Service_State_Id smallint NULL,
CRM_Service_State AS CASE WHEN Service_State_Id=1 Then 'In queue' WHEN Service_State_Id=2 Then 'In Process' WHEN Service_State_Id=3 Then 'Completed' WHEN Service_State_Id=3 Then 'Cancelled' PERSISTED
);
Don’t forget to
ENDyour cases:Nothing wrong with multiple compute columns, as far as I know.