--动态SQL语句.
declare @s varchar(8000)
set @s=''
select @s=@s+' union all select data1,data2 from ['+name+']'
from sysobjects where name like 'table%' --或: in('要查询的表1','要查询的表2')
set @s=substring(@s,12,8000)
exec('insert into NewTable '+@s)
declare @s varchar(8000)
set @s=''
select @s=@s+' union all select data1,data2 from ['+name+']'
from sysobjects where name like 'table%' --或: in('要查询的表1','要查询的表2')
set @s=substring(@s,12,8000)
exec('insert into NewTable '+@s)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货