CREATE function f_GetFirstPy(@str varchar(50)='')
returns char(1)
as
begin
declare @n int, @c char(1), @chn nchar(1)
select @n=63, @chn=substring(@str,1,1)
if @chn > 'z'
if( @chn < '八' ) set @c = 'A'
else if ( @chn < '嚓' ) set @c = 'B'
else if ( @chn < '咑' ) set @c = 'C'
else if ( @chn < '妸' ) set @c = 'D'
else if ( @chn < '发' ) set @c = 'E'
else if ( @chn < '旮' ) set @c = 'F'
else if ( @chn < '铪' ) set @c = 'G'
else if ( @chn < '丌' ) set @c = 'H'
else if ( @chn < '丌' ) set @c = 'I'
else if ( @chn < '咔' ) set @c = 'J'
else if ( @chn < '垃' ) set @c = 'K'
else if ( @chn < '嘸' ) set @c = 'L'
else if ( @chn < '拏' ) set @c = 'M'
else if ( @chn < '噢' ) set @c = 'N'
else if ( @chn < '妑' ) set @c = 'O'
else if ( @chn < '七' ) set @c = 'P'
else if ( @chn < '呥' ) set @c = 'Q'
else if ( @chn < '仨' ) set @c = 'R'
else if ( @chn < '他' ) set @c = 'S'
else if ( @chn < '屲' ) set @c = 'T'
else if ( @chn < '屲' ) set @c = 'U'
else if ( @chn < '屲' ) set @c = 'V'
else if ( @chn < '夕' ) set @c = 'W'
else if ( @chn < '丫' ) set @c = 'X'
else if ( @chn < '帀' ) set @c = 'Y'
else set @c = 'Z'
else if @chn <= 'z' and @chn >= 'a'
set @c = upper(@chn)
else if @chn <= 'Z' and @chn >= 'A'
set @c = @chn
else
set @c = ''
return (@c)
end