/*--修改自定义数据类型精度
![](/icons/20918de.gif)
自定义数据类型
![](/icons/20918yi.gif)
![](/icons/20918de.gif)
![](/icons/20918de.gif)
假设要修改
![](/icons/20918de.gif)
--*/
--1.修改自定义变量类型
![](/icons/20918de.gif)
exec sp_rename \'aa\',\'aa_bak\',\'USERDATATYPE\'
go
--2.新增自定义变量(按新
![](/icons/20918de.gif)
EXEC sp_addtype N\'aa\', N\'numeric(20,2)\', N\'not null\'
go
--3.修改表,使用新增
![](/icons/20918de.gif)
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 _disibledevent=>where b.name=\'aa_bak\'
open tb
fetch next from tb
![](/icons/20918int.gif)
while @@fetch_status=0
begin
exec(@s)
fetch next from tb
![](/icons/20918int.gif)
end
close tb
deallocate tb
最新评论