解决方案 »

  1.   

    用动态SQL实现,declare @tsql varchar(6000)select @tsql=isnull(@tsql+',','')+List
     from a
     where id<3
     
    select @tsql='select * from b where id in('+@tsql+')'exec(@tsql)/*
    id          Name
    ----------- --------------
    1           A
    2           B
    3           C
    13          D
    28          E
    44          F(6 行受影响)
    */
      

  2.   


    -- 可以考虑使用 like 
    select b.* from b , a 
    where ',' + a.List + ',' like '%,' + cast(b.id as varchar(10)) + ',%'
    go
    id          Name
    ----------- -------------
    1           A
    2           B
    3           C
    13          D
    28          E
    44          F(6 行受影响)