|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
MySQL是一个开放源码的小型关联式数据库管理系统,开发者为瑞典MySQLAB公司。目前MySQL被广泛地应用在Internet上的中小型网站中。server|年夜写|金额|小写
原作在SQL2000中有一些成绩。修改毛病并在SQL2000中运转经由过程。
/********************************************************
(wleii165@yahoo.com)
版本:1.0
创立工夫:20020227
修正工夫:
功效:小写金额转换成年夜写
参数:n_LowerMoney小写金额
v_TransType品种--1:directlytranslate,0:readitinwords
输入:年夜写金额
********************************************************/
CREATEPROCEDUREdbo.L2U
(
@n_LowerMoneynumeric(15,2),
@v_TransTypeint,
@RETVARCHAR(200)output
)
AS
Declare@v_LowerStrVARCHAR(200)--小写金额
Declare@v_UpperPartVARCHAR(200)
Declare@v_UpperStrVARCHAR(200)--年夜写金额
Declare@i_Iint
setnocounton
select@v_LowerStr=LTRIM(RTRIM(STR(@n_LowerMoney,20,2)))--四舍五进为指定的精度并删除数据摆布空格
select@i_I=1
select@v_UpperStr=
while(@i_I<=len(@v_LowerStr))
begin
select@v_UpperPart=casesubstring(@v_LowerStr,len(@v_LowerStr)-@i_I+1,1)
WHEN.THEN元
WHEN0THEN零
WHEN1THEN壹
WHEN2THEN贰
WHEN3THEN叁
WHEN4THEN肆
WHEN5THEN伍
WHEN6THEN陆
WHEN7THEN柒
WHEN8THEN捌
WHEN9THEN玖
END
+
case@i_I
WHEN1THEN分
WHEN2THEN角
WHEN3THEN
WHEN4THEN
WHEN5THEN拾
WHEN6THEN佰
WHEN7THEN仟
WHEN8THEN万
WHEN9THEN拾
WHEN10THEN佰
WHEN11THEN仟
WHEN12THEN亿
WHEN13THEN拾
WHEN14THEN佰
WHEN15THEN仟
WHEN16THEN万
ELSE
END
select@v_UpperStr=@v_UpperPart+@v_UpperStr
select@i_I=@i_I+1
end
--------print//v_UpperStr=+@v_UpperStr+//
if(@v_TransType=0)
begin
select@v_UpperStr=REPLACE(@v_UpperStr,零拾,零)
select@v_UpperStr=REPLACE(@v_UpperStr,零佰,零)
select@v_UpperStr=REPLACE(@v_UpperStr,零仟,零)
select@v_UpperStr=REPLACE(@v_UpperStr,零零零,零)
select@v_UpperStr=REPLACE(@v_UpperStr,零零,零)
select@v_UpperStr=REPLACE(@v_UpperStr,零角零分,整)
select@v_UpperStr=REPLACE(@v_UpperStr,零分,整)
select@v_UpperStr=REPLACE(@v_UpperStr,零角,零)
select@v_UpperStr=REPLACE(@v_UpperStr,零亿零万零元,亿元)
select@v_UpperStr=REPLACE(@v_UpperStr,亿零万零元,亿元)
select@v_UpperStr=REPLACE(@v_UpperStr,零亿零万,亿)
select@v_UpperStr=REPLACE(@v_UpperStr,零万零元,万元)
select@v_UpperStr=REPLACE(@v_UpperStr,万零元,万元)
select@v_UpperStr=REPLACE(@v_UpperStr,零亿,亿)
select@v_UpperStr=REPLACE(@v_UpperStr,零万,万)
select@v_UpperStr=REPLACE(@v_UpperStr,零元,元)
select@v_UpperStr=REPLACE(@v_UpperStr,零零,零)
end
--对壹元以下的金额的处置
if(substring(@v_UpperStr,1,1)=元)
begin
select@v_UpperStr=substring(@v_UpperStr,2,(len(@v_UpperStr)-1))
end
if(substring(@v_UpperStr,1,1)=零)
begin
select@v_UpperStr=substring(@v_UpperStr,2,(len(@v_UpperStr)-1))
end
if(substring(@v_UpperStr,1,1)=角)
begin
select@v_UpperStr=substring(@v_UpperStr,2,(len(@v_UpperStr)-1))
end
if(substring(@v_UpperStr,1,1)=分)
begin
select@v_UpperStr=substring(@v_UpperStr,2,(len(@v_UpperStr)-1))
end
if(substring(@v_UpperStr,1,1)=整)
begin
select@v_UpperStr=零元整
end
select@ret=@v_UpperStr
GO
挪用历程:
declare@retvarchar(200)
execL2U567983.897,1,@retoutput
select@ret
虽然可以将一个droptable语句转换成先delete再删表,性能却会降低很多。这里我们用上面说道的另外一种可用数据:“操作前数据备份”。 |
|