insert into [新表] select *,1101 from [数据1101] union select *,1102 from [数据1102] union select *,1103 from [数据1103] ……
select * into new_table from ( select *,1101 [time] from [数据1101] union all select *,1102 from [数据1102] union all select *,1103 from [数据1103] ... ) a
--得到结果中去掉最后一个union all select 'select *,'+replace(name,'数据','')+' as [time] from '+name +' union all' from sys.objects where type ='u' and name like '数据%'
select *,1101 from [数据1101]
union
select *,1102 from [数据1102]
union
select *,1103 from [数据1103]
……
into new_table
from (
select *,1101 [time] from [数据1101]
union all
select *,1102 from [数据1102]
union all
select *,1103 from [数据1103]
... ) a
select 'select *,'+replace(name,'数据','')+' as [time] from '+name +' union all'
from sys.objects
where type ='u' and name like '数据%'