34,590
社区成员
发帖
与我相关
我的任务
分享
declare @a varchar(20)
declare @length int
declare @dec int
set @a='sss'
set @length=18
set @dec=4
exec('alter table sc add '+@a+' decimal('+ @length +' ,'+ @dec +') ')
create table hello(id int)
declare @sql varchar(100),@a varchar(10),@length int,@dec int
select @a='name',@length=5,@dec=2
set @sql='alter table hello add '+@a+' decimal('+ltrim(@length)+','+ltrim(@dec)+')'
exec( @sql )
select * from hello
exec('alter table hello add '+@a +' decimal('+ltrim(@length)+','+ltrim(@dec)+')')
exec('alter table hello add '+@a +'decimal('+ltrim(@length)+','+ltrim(@dec)+''')