declare @strCol varchar(8000)
set @strCol=''
select @strCol=@strCol+' int, '+ hz from table1
set @strCol=substring(@strcol,7,8000)
exec ('create table tablename (' + @strCol + ')')
set @strCol=''
select @strCol=@strCol+' int, '+ hz from table1
set @strCol=substring(@strcol,7,8000)
exec ('create table tablename (' + @strCol + ')')
set @code='01%' --要产生表2的条件--生成表2的处理
declare @s varchar(8000)
set @s=''
select @s=',['+hz+'] int' from 表1 where code like @code
set @s=substring(@s,2,8000)
exec('create table 表2('+@s+')')