declare @type as int
declare @id as int
set @type=3
set @id=1
SELECT   
      CASE 
         WHEN @type in(1,4,6) THEN 
select 
case 
when @id in(1) then 'A'
when @id in(2) then 'a'
end
         WHEN @type in(2,5) THEN 
select 
case 
when @id in(1) then 'B'
when @id in(2) then 'b'
end
         WHEN @type in(3) THEN 'C'
      END

解决方案 »

  1.   

    SELECT   
          CASE 
             WHEN @type in(1,4,6) THEN 
    case 
    when @id in(1) then 'A'
    when @id in(2) then 'a'
    end
             WHEN @type in(2,5) THEN 
    case 
    when @id in(1) then 'B'
    when @id in(2) then 'b'
    end
             WHEN @type in(3) THEN 'C'
          END
      

  2.   

    declare @type as int
    declare @id as int
    set @type=3
    set @id=1
    SELECT   
          CASE 
             WHEN @type in(1,4,6) THEN 
    --select 
    case 
    when @id in(1) then 'A'
    when @id in(2) then 'a'
    end
             WHEN @type in(2,5) THEN 
    --select 
    case 
    when @id in(1) then 'B'
    when @id in(2) then 'b'
    end
             WHEN @type in(3) THEN 'C'
          END
      

  3.   

    declare @type as int
    declare @id as int
    set @type=3
    set @id=1
    SELECT   
          CASE 
             WHEN @type in(1,4,6) THEN 
    --select 
    case 
    when @id in(1) then 
                                                 --如何执行一系列语句呢
    when @id in(2) then 
                                                 --如何执行一系列语句呢
    end
             WHEN @type in(2,5) THEN 
    --select 
    case 
    when @id in(1) then 
                                                 --如何执行一系列语句呢'
    when @id in(2) then 
                                                 --如何执行一系列语句呢
    end
             WHEN @type in(3) THEN 
                                                 --如何执行一系列语句呢
          END
      

  4.   

    declare @type as int
    declare @id as int
    set @type=3
    set @id=1
    SELECT   
          CASE 
             WHEN @type in(1,4,6) THEN 
    --select 
    case 
    when @id in(1) then 
                                                 --如何执行一系列语句呢
                                                 --update table1 set a='A',b='1'
                                                 --update table2 set a='A',b='2'
    when @id in(2) then 
                                                 --如何执行一系列语句呢
                                                 --update table1 set a='B',b='2'
                                                 --update table2 set a='B',b='3'
    end
             WHEN @type in(2,5) THEN 
    --select 
    case 
    when @id in(1) then 
                                                 --如何执行一系列语句呢'
                                                 --update table1 set a='C',b='4'
                                                 --update table2 set a='C',b='5' when @id in(2) then 
                                                 --如何执行一系列语句呢
                                                 --update table1 set a='C',b='4'
                                                 --update table2 set a='C',b='5' end
             WHEN @type in(3) THEN 
                                                 --如何执行一系列语句呢
                                                 --update table1 set a='D',b='6'
                                                 --update table2 set a='D',b='7'      END