declare @tname nvarchar(255)=N'要修改的表名'; --修改所有以sl结尾的列名的小数位数为4位 select syscolumns.name into #t1 from syscolumns,systypes where syscolumns.xusertype = systypes.xusertype and syscolumns.id = object_id(@tname) and syscolumns.name like '%sl' and systypes.name='numeric'; while exists(select top 1 name from #t1) begin declare @cname varchar(255); select top 1 @cname=name from #t1 delete #t1 where name=@cname; declare @sql nvarchar(1000); set @sql=N'alter table '+@tname+' alter column '+@cname+' numeric(19,4)'; exec sp_executesql @sql; end drop table #t1;