1, the number of characters to convert to Chinese capital,
Attention
100==> 100 rather than ==> 100
123==> 123 rather than ==> 123
CREATE FUNCTIONFn_numberconvertchinase (@number NVARCHAR( -))RETURNS NVARCHAR( -) asBEGINDECLARE @res NVARCHAR( -)DECLARE @char CHAR(1)SET @res = "'SET @char = substring(@number,1,1)SELECT @res =( Case @char when '1' Then 'a' when '2' Then 'two' when '3' Then 'three' when '4' Then 'Four' when '5' Then 'Five' when '6' Then 'Six' when '7' Then 'Seven' when '8' Then 'Eight' when '9' Then 'Nine' when '0' Then '0' ELSE substring(@number,1,1)END )IF(Len(@number)> 1)BEGIN SET @res = @res +Dbo.fn_numberconvertchinase (substring(@number,2,Len(@number)-1))ENDRETURN @res END
2. Get the first letter of the character and turn it into uppercase
CREATE FUNCTIONFn_getpy (@str NVARCHAR(4000))RETURNS NVARCHAR(4000) asBEGIN DECLARE @strlen INT; DECLARE @re NVARCHAR(4000); --Digit to uppercase in character SELECT @str=Dbo.fn_numberconvertchinase (@str); DECLARE @t Table(CHRnchar(1) Collate Chinese_prc_ci_as,letternchar(1)) INSERT into @t(Chr,letter)SELECT 'Acridine','A' UNION All SELECT 'Eight','B' UNION All SELECT 'Cha','C' UNION All SELECT 'Otah','D' UNION All SELECT 'Ehegan','E' UNION All SELECT 'Hair','F' UNION All SELECT 'Xu','G' UNION All SELECT 'hafnium','H' UNION All SELECT ' not','J' UNION All SELECT 'ka','K' UNION All SELECT ' Garbage','L' UNION All SELECT '嘸','M' UNION All SELECT 'Hallasan','N' UNION All SELECT 'Oh','O' UNION All SELECT '妑','P' UNION All SELECT 'Seven','Q' UNION All SELECT '呥','R' UNION All SELECT 'SA','S' UNION All SELECT 'his','T' UNION All SELECT '屲','W' UNION All SELECT 'XI','X' UNION All SELECT 'ya','Y' UNION All SELECT 'as','Z'; SELECT @strlen=Len(@str),@re="'; while @strlen>0 BEGIN SELECT TOP 1 @re=Letter+@re,@strlen=@strlen-1 from @tAWHEREChr<=substring(@str,@strlen,1) ORDER byChrDESC IF @ @rowcount=0 SELECT @re=substring(@str,@strlen,1)+@re,@strlen=@strlen-1 END RETURN(UPPER(@re))END
SQL character numbers convert letters