所有表的结构相同,只是表名没有规律。

解决方案 »

  1.   

    select * from table1
    union all
    select * from table2
    union all
    .............
      

  2.   

    再复杂的情况就不好说了,比如存储过程中有case when和动态列表,再用union就不好连接了!
      

  3.   

    delete from data_all
    declare @sqlcmd varchar(8000)
    set @sqlcmd=''
    select @sqlcmd=@sqlcmd + 'insert into [data_all] select * from [' + name + '];' from sysobjects where xtype='u' and name<>'data_all' and name<>'dtproperties'
    exec (@sqlcmd)