首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 昨夜看到谁谁的数字转英文帖子, 咋不见了?! [已结贴,结贴人:qianjin036a]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:21:59 楼主
    做了两个函数,实现帖子上说的数字转英文.
    当散分了!
    SQL code
    -- ============================================= -- Author: Author,qianjin036a -- Create date: Create Date,06/14/2008 02:27:17 -- Description: Description,Arabic numerals to English -- ============================================= CREATE FUNCTION Digit2English ( @arabia decimal(38,17) ) RETURNS varchar(1000) AS BEGIN declare @atoe table(a int,e varchar(10)) insert into @atoe select 0,'zero' union all select 1,'one' union all select 2,'two' union all select 3,'three' union all select 4,'four' union all select 5,'five' union all select 6,'six' union all select 7,'seven' union all select 8,'eight' union all select 9,'nine' declare @integer bigint,@trillion int,@billion int,@million int,@thousand int,@hundred int,@english varchar(1000) select @integer=@arabia,@english='' select @trillion=@integer % 1000000000000000/1000000000000,@billion=@integer % 1000000000000/1000000000, @million=@integer % 1000000000/1000000,@thousand=(@integer % 1000000)/1000,@hundred=(@integer % 1000) if @trillion>0 set @english=@english + dbo.ThreeDigit(@trillion) + 'trillion ' if @billion>0 set @english=@english + dbo.ThreeDigit(@billion) + 'billion ' if @million>0 set @english=@english + dbo.ThreeDigit(@million) + 'million ' if @thousand>0 set @english=@english + dbo.ThreeDigit(@thousand) + 'thousand ' if @hundred>0 set @english=@english + dbo.ThreeDigit(@hundred) if @english='' set @english='zero ' if @arabia-@integer>0.000000000 begin declare @decimal decimal(18,17) select @english=@english+'point ',@decimal=@arabia-@integer while @decimal>0.0 begin select @english=@english+e+' ' from @atoe where cast(@decimal*10 as int)=a set @decimal=@decimal*10-cast(@decimal*10 as int) end end return @english END GO -- ============================================= -- Author: Author,qianjin036a -- Create date: Create Date,06/14/2008 02:27:17 -- Description: Description,Three Digit Arabic numerals to English -- ============================================= CREATE FUNCTION ThreeDigit ( @integer int ) RETURNS varchar(100) WITH EXECUTE AS CALLER AS BEGIN declare @atoe table(a int,e varchar(10)) insert into @atoe select 0,'zero' union all select 1,'one' union all select 2,'two' union all select 3,'three' union all select 4,'four' union all select 5,'five' union all select 6,'six' union all select 7,'seven' union all select 8,'eight' union all select 9,'nine' union all select 10,'ten' union all select 11,'eleven' union all select 12,'twelve' union all select 13,'thirteen' union all select 14,'fourteen' union all select 15,'fifteen' union all select 16,'sixteen' union all select 17,'seventeen' union all select 18,'eighteen' union all select 19,'nineteen' union all select 20,'twenty' union all select 30,'thirty' union all select 40,'forty' union all select 50,'fifty' union all select 60,'sixty' union all select 70,'severty' union all select 80,'eighty' union all select 90,'ninety' declare @english varchar(100) set @english='' if @integer>99 begin select @english=e+' hundred ' from @atoe where @integer/100=a set @integer=@integer % 100 if @integer>0 set @english=@english+'and ' end if @integer<=20 and @integer>0 select @english=@english+e+' ' from @atoe where @integer=a if @integer>20 begin select @english=@english+e+' ' from @atoe where @integer/10*10=a set @integer=@integer % 10 if @integer>0 select @english=@english+e+' ' from @atoe where @integer=a end RETURN @english END GO select dbo.digit2english(123456789987654.321) union all select dbo.digit2english(120045080045054.8412) union all select dbo.digit2english(0.0102541) go /* --------------------------------------------------------------------------------------------------------------- one hundred and twenty three trillion four hundred and fifty six billion seven hundred and eighty nine million nine hundred and eighty seven thousand six hundred and fifty four point three two one one hundred and twenty trillion forty five billion eighty million forty five thousand fifty four point eight four one two zero point zero one zero two five four one (3 行受影响) */
    100  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:23:311楼 得分:8
    sf
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • liangCK
    • 等级:
    发表于:2008-06-14 12:24:002楼 得分:8
    很强大.
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:26:183楼 得分:8
    强!
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:41:014楼 得分:8
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:41:245楼 得分:0
    太牛了
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:41:536楼 得分:0
    使劲接楼主的分
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:42:437楼 得分:0
    搂主要多散分,得分时才会多得分的 :)
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:43:478楼 得分:0
    不过要在sql升星,真的很难,刷帖的太多了   
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:44:079楼 得分:0
    支持楼主
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 12:47:2910楼 得分:0
    引用 8 楼 wzy_love_sly 的回复:
    不过要在sql升星,真的很难,刷帖的太多了   


    结帖率约20%
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • liangCK
    • 等级:
    发表于:2008-06-14 12:51:0611楼 得分:0
    引用 8 楼 wzy_love_sly 的回复:
    不过要在sql升星,真的很难,刷帖的太多了   


    比如你就是一个典型的例子..
    这里技术区.
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 13:07:2112楼 得分:8
    很强大
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 13:10:3513楼 得分:8
    ...................
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 13:14:3414楼 得分:8
    收藏先
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • sweetweiwei
    • 等级:
    发表于:2008-06-14 13:17:2615楼 得分:8
    ...
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 13:32:3016楼 得分:6
    up
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 13:44:5317楼 得分:0
    引用 10 楼 qianjin036a 的回复:
    引用 8 楼 wzy_love_sly 的回复:
    不过要在sql升星,真的很难,刷帖的太多了
    结帖率约20%


    哈哈,那还真少了点
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 13:46:3418楼 得分:0
    引用 11 楼 liangCK 的回复:
    引用 8 楼 wzy_love_sly 的回复:
    不过要在sql升星,真的很难,刷帖的太多了
    比如你就是一个典型的例子..
    这里技术区.

    无视梁子的话....
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 13:47:1119楼 得分:6
    呵呵~~
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 13:48:0220楼 得分:0
    飘过~
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-14 15:10:4021楼 得分:6
    支持

    感谢分享
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-15 11:41:5722楼 得分:6
    强悍
    支持
    分享
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信