create proc sp_test
@table varchar(200)
as
exec('select * from ' + @table);

解决方案 »

  1.   


    --这样?
    create proc proc_name
    as
      select col from tb1 union all
      select col from tb2 union all
      ...
      

  2.   

    select * from table1
    union all
    select * from table2
    union all
    select * from table3
    union all
    select * from table4
    union all
    select * from table5
    union all
    select * from table6
      

  3.   

    其实这样做没啥意义,直接在客户端写Select语句算了。
      

  4.   

    create proc proc_name
    as
      select * from tb1
      select * from tb2
      select * from tb3
      select * from tb4
      select * from tb5
      select * from tb6
    go在程序中可以用DataSet来接收存储过程产生的结果集,6个结果集会存放在6个DataTable中。