Ylbtech-sql server-function:f_getpy |
1, F_getpy
Create function [dbo].[f_getpy](@str nvarchar(4000)) returns nvarchar(4000) as begin Declare @strlen int,@re nvarchar(4000) 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(@re) End
2.
|
Ylbtech Source: http://storebook.cnblogs.com/ This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility. |
Dbs-function:f_getpy