CREATE FUNCTION fn_numtoletter
(
@key NVARCHAR(10)
)
RETURNS VARCHAR(10)
AS
BEGIN
DECLARE @code VARCHAR(10)
if(LEN(@key)=1)
begin
SET @code=@key
end
if(LEN(@key)=2)
begin
SET @code=case
when @key='00' then '0'
when @key='01' then '1'
when @key='02' then '2'
when @key='03' then '3'
when @key='04' then '4'
when @key='05' then '5'
when @key='06' then '6'
when @key='07' then '7'
when @key='08' then '8'
when @key='09' then '9'
when @key='10' then 'A'
when @key='11' then 'B'
when @key='12' then 'C'
when @key='13' then 'D'
when @key='14' then 'E'
when @key='15' then 'F'
when @key='16' then 'G'
when @key='17' then 'H'
when @key='18' then 'I'
when @key='19' then 'J'
when @key='20' then 'K'
when @key='21' then 'L'
when @key='22' then 'M'
when @key='23' then 'N'
when @key='24' then 'O'
when @key='25' then 'P'
when @key='26' then 'Q'
when @key='27' then 'R'
when @key='28' then 'S'
when @key='29' then 'T'
when @key='30' then 'U'
when @key='31' then 'V'
else '大于31' end
end
RETURN @code
END