标题: 修改自定义数据类型精度
ljjk5
元帅
Rank: 1


荣誉会员奖章
UID 46706
精华 1
积分 99426
帖子 49691
威望 554
金币 48489
热心 505
阅读权限 100
注册 2007-2-25
状态 离线
修改自定义数据类型精度

/*--修改自定义数据类型精度的示例
     自定义数据类型一旦被引用,就不能再修改和删除,如果要修改数据的精度,就非常麻烦,下面的示例演示了如何修改
     假设要修改的自定义变量名为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   

网友 ljjk5 签名 - 网友社区 ===
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-9-5 12:30
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP