select * from table1 union all select * from table2 union all .............
再复杂的情况就不好说了,比如存储过程中有case when和动态列表,再用union就不好连接了!
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)
union all
select * from table2
union 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)