有没有办法合并以下内容并在@FH_RecordKey
或@VF_dept_seq
声明中设置SET
和SELECT
?
set @FH_RecordKey =(
case @lnktble
when 'ems' then (select FH_inci_id from FH_Catherine_live.dbo.FH_MAP_EMS_INCI where VF_ems_seq = @tempseq)
when 'imaster' then (select FH_insp_id from FH_Catherine_live.dbo.FH_MAP_INSPID where VF_in_seq = @tempseq)
when 'n5basic' then (select inci_id from [dbo].[VF_IncWorkTable] where inc_seq = @tempseq)
END)
set @VF_dept_seq = (
case @lnktble
when 'ems' then (select VF_dept_seq from FH_Catherine_Live.dbo.FH_MAP_EMS_INCI where VF_ems_seq = @tempseq)
when 'imaster' then (select VF_dept_seq from FH_Catherine_Live.dbo.FH_MAP_INSPID where VF_in_seq = @tempseq)
when 'n5basic' then (select dept_seq from [dbo].[VF_IncWorkTable] where inc_seq = @tempseq)
end)
答案 0 :(得分:1)
使用IF
语句而不是CASE
IF @lnktble = 'ems'
select @FH_RecordKey = FH_inci_id ,@VF_dept_seq = VF_dept_seq
from FH_Catherine_live.dbo.FH_MAP_EMS_INCI
where VF_ems_seq = @tempseq
ELSE IF @lnktble = 'imaster' /*...*/
答案 1 :(得分:0)
Select @FH_RecordKey =
(case statement here),
@VF_dept_seq =
(case statement here)