For example, enter 12345, Program Given: tens of thousands of employees
For example, enter 10023040, and the program will provide the following information:
One solution (tested in sqlserver2000 ):
Create Function fun_cgnum
(@ Num INT)
Returns varchar (100)
As
Begin
Declare @ temp int, @ Res Int, @ I tinyint
Declare @ STR varchar (100), @ No varchar (20), @ unit varchar (16)
Select @ STR = '', @ No = 'another employee, Wu Luhan, Wu luyun, @ unit = 'yaohan wanzhibaibaibaibaibaiyi'
Set @ temp = @ num
Select @ I = 0, @ res = @ TEMP % 10, @ temp = @ temp/10
While @ temp> 0
Begin
If @ I = 0
Set @ STR = substring (@ No, @ res + 1, 1)
Else
Set @ STR = substring (@ No, @ res + 1,1) + substring (@ unit, @ I, 1) + @ Str
Select @ res = @ TEMP % 10, @ temp = @ temp/10
Set @ I = @ I + 1
End
Set @ STR = substring (@ No, @ res + 1,1) + substring (@ unit, @ I, 1) + @ Str
Set @ STR = Replace (@ STR, 'taobao', 'taobao ')
Set @ STR = Replace (@ STR, 'taobao', 'taobao ')
Set @ STR = Replace (@ STR, 'taobao', 'taobao ')
Set @ STR = Replace (@ STR, 'taobao', 'taobao ')
Set @ STR = Replace (@ STR, 'wan Wan ', 'wan ')
While @ I> 0
Begin
Set @ STR = Replace (@ STR, 'others', 'others ')
Set @ I = charindex ('others', @ Str)
End
Set @ STR = Replace (@ STR, 'wan Wan ', 'wan ')
Set @ STR = Replace (@ STR, 'billionaire, '')
If right (@ STR, 1) = 'others'
Set @ STR = left (@ STR, Len (@ Str)-1)
Return @ Str
End
Go
-- Test: zero or zero
Select DBO. fun_cgnum (900000000), DBO. fun_cgnum (903002051), DBO. fun_cgnum (903002050)
PS: If you are interested, you can continue to consider the number of decimal points and the unit of adding (Yuan/angle/points ).