create table tz2008_1_1(id int,name varchar(50))
insert into tz2008_1_1 select 1,'a'
create table tz2008_1_2(id int,name varchar(50))
insert into tz2008_1_2 select 2,'b'
create table tz2008_1_3(id int,name varchar(50))
insert into tz2008_1_3 select 3,'c'
declare @sql varchar(8000)
select @sql=isnull(@sql+' union all ','')+' select * from ['+name+']'
from sysobjects where xtype='u' and name like 'tz2008%'
exec(@sql)
本文介绍了一种在数据库中批量创建多个表的方法,并通过动态构建SQL语句的方式实现了对这些表的数据查询。此方法适用于需要快速搭建多个相似结构表的场景。
4255

被折叠的 条评论
为什么被折叠?



