Declare @I Int
declare @sql Varchar(8000)
Set @I=1
While @I<=20
Begin
Set @sql='Create table ghy'+Rtrim(@I)+' (ID Int)'
EXEC(@sql)
Set @I=@I+1
End
解决方案 »
- 推荐几本业务性很强的sql[学习资料].天天看基础,脾气很暴燥.
- 在程序中如何中断一个查询或正在执行的存储过程
- 各位好,向大家求一简单视图。
- 请教mysql查询问题?
- 是不是该生成一个表?
- 如何用Select语句来选择第1行,第4行,第7行,第10行 ..?(急)
- sqlserver 同 ORACLE 有什么区别(概念上的,O方案) 可以推荐几个学习ORACLE的网站吗
- sql server 的数据通用性
- 在sql server 中如何更改服务器的名字(十万火急!!!!!!!!!)
- update表时,忘了加条件,结果全部数据都被改为一样了,能否再恢复啊??!
- 怎样把三个表插入到另外一个表中的image字段,然后再读出来?求助。
- 如何 设置 两个 sql server2000 的 "出版" 和 "发布" ?????????????????
set @a = 0
while @a < 20
begin
exec('create table test'+@a +'(a int)')
select @a=@a+1
end
===============================
后面的a int 为您的表中的列名
insert into ghy
values(1,2,3)
declare @a int
declare @b varchar(6)set @a=1
while @a<21
begin
set @b='ghy'+Rtrim(@a)
--exec('select * into '+@b+' from ghy where 1<>1') --不要把表裡數據copy過去
--exec('select * into '+@b+' from ghy ' ) -- 要把表裡數據copy過去--exec('drop table '+@b) --刪除所新增的表
set @a=@a+1
end
drop table ghy