I am trying to load multiple variables in the same query like this
declare @currentUserPersonnelNumber int
declare @draftWorkFlowStatusId int
declare @diWorkFlowStatusId int
declare @ibWorkFlowStatusId int
declare @ipWorkFlowStatusId int
select
@draftWorkFlowStatusId = case when WFStep='DR' then WorkFlowId else NULL end,
@diWorkFlowStatusId = case when WFStep='DI' then WorkFlowId else NULL end,
@ibWorkFlowStatusId = case when WFStep='IB' then WorkFlowId else NULL end,
@ipWorkFlowStatusId = case when WFStep='IP' then WorkFlowId else NULL end
from WorkFlow
But only second variable @diWorkFlowStatusId is getting populated and not all.
What is wrong am I doing?
When I do it this way all the variable gets loaded properly, but I think that is not the right way
declare @draftWorkFlowStatusId int = (SELECT WorkFlowId FROM [WorkFlow] WHERE WFStep = 'DR')
declare @diWorkFlowStatusId int = (SELECT WorkFlowId FROM [WorkFlow] WHERE WFStep = 'DI')
declare @ibWorkFlowStatusId int = (SELECT WorkFlowId FROM WorkFlow WHERE WFStep = 'IB')
declare @ipWorkFlowStatusId int = (SELECT WorkFlowId FROM WorkFlow WHERE WFStep = 'IP')