declare @ww varchar(50)
set @ww='select staff_id from ZC_Staff'
select * from ZC_Staff where staff_id in exec(@ww)
上面的为什么会报错!!

解决方案 »

  1.   

    declare @ww varchar(50)
    set @ww='select * from ZC_Staff where staff_id in(select staff_id from ZC_Staff)'
    exec(@ww)
      

  2.   

    declare @ww varchar(200)
    set @ww='select * from ZC_Staff where staff_id in(select staff_id from ZC_Staff)'
    exec(@ww)
      

  3.   

    declare @ww varchar(50)
    set @ww='select staff_id from ZC_Staff'
    select * from ZC_Staff where staff_id in exec(@ww)
    你的语句是查询一个表的所有列?是否写法有得多余?