create proc sp_AA
  @table  varchar(100)
as
    exec('select * from A where A.f1 in (select f1 from '+@table+') a')
go

解决方案 »

  1.   

    create proc sp_AA
      @table  varchar(10)  
    as
    exec('select * from A where A.f1 in (select f1 from '+ @table+')')
      

  2.   

    create proc sp_AA
      @table  varchar(100)
    as
        exec('select * from A where A.f1 in (select f1 from '+@table+')')
      

  3.   

    条件也是一样的呀,都用动态SQL:create proc sp_AA
      @sql  varchar(100)
    as
        exec('select * from A where A.f1 in '+@sql)
      

  4.   

    create proc sp_AA
      @sql  varchar(100)
    as
        exec('select * from A where A.f1 in ('+@sql+')')