1

以下と set を組み合わせて 1 つの or ステートメントにする方法は@FH_RecordKeyあり@VF_dept_seqますSETSELECT?

    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)
4

2 に答える 2

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' /*...*/
于 2012-06-27T13:08:25.580 に答える
0
Select @FH_RecordKey = 
  (case statement here),
@VF_dept_seq = 
  (case statement here)
于 2012-06-27T12:30:19.610 に答える