--1.修改自定义变量类型的名称 exec sp_rename 'aa','aa_bak','userdatatype' go
--2.新增自定义变量(按新的精度) exec sp_addtype n'aa', n'numeric(20,2)', n'not null' go
--3.修改表,使用新增的自定义变量
declare @s varchar(8000) declare tb cursor local for select 'alter table ['+object_name(a.id)+'] alter column [' +a.name+'] aa' from syscolumns a join systypes b on a.xusertype=b.xusertype where b.name='aa_bak' open tb fetch next from tb into @s while @@fetch_status=0 begin exec(@s) fetch next from tb into @s end close tb deallocate tb