For example, enter 12345, and the program will show you:
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 ).