现在的位置: 首页 > 综合 > 正文

用存储过程循环创建表

2013年09月22日 ⁄ 综合 ⁄ 共 178字 ⁄ 字号 评论关闭

declare @a varchar(256)
set @a=0
while @a<5
begin
exec('select * into test'+@a+' from FlightData')
set @a=@a+1
end

 

这样就创建test1、test2、test3、test4、test5这五个表,

不能直接用select * into @a from FlightData,这样有语法错误

【上篇】
【下篇】

抱歉!评论已关闭.