
/*--修改自定义数据类型精度的示例
自定义数据类型一旦被引用,就不能再修改和删除,如果要修改数据的精度,就非常麻烦,下面的示例演示了如何修改
假设要修改的自定义变量名为aa
--*/
--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
正在阅读:
2017计算机等考三级数据库知识辅导:修改自定义数据类型精度12-03
天津小升初外地户口可以入学吗|2017天津小升初入学流程02-06
奉献是一种美德作文800字10-06
贵州省2019年中考查分入口03-30
生命的接力作文10-29
图书馆年度工作计划202110-29
2017广东汕尾中考成绩几天出来01-11
2022年甘肃甘南州考区三支一扶基层服务项目考试考生疫情防控告知书06-21
护士年终述职报告02-09
新概念英语词汇第一册Lesson77:你约好了吗?06-25
最新教师入党思想汇报范文08-01