34,588
社区成员
发帖
与我相关
我的任务
分享
[code=SQL]select T1.*,T2.*
into T3
FROM T1,T2
select
'alter table b add '+tp.[name] +
case when col.user_type_id in (231,239) then '('+convert(varchar(10),col.max_length)+')'
when col.user_type_id in (106,108) then '('+convert(varchar(10),col.max_length)+','+convert(varchar(10),col.scale)+')' else ' ' end +
case when col.is_nullable = 0 then ' not null' else ' null' end
from sys.types as tp
inner join
sys.columns as col
on tp.user_type_id = col.user_type_id
where col.object_id = object_id('b')