sql 函数的创建

create function dbo.GetNumber(@Num varchar(32))
returns varchar(32)
as
begin
declare @i int
while patindex('%[a-Z]%',@Num) > 0
begin
set @i = patindex('%[a-Z]%',@Num)
set @Num = stuff(@Num,@i,1,'')
end
set @Num = replace(@Num,' ','')
return @Num
end

 

Create  Function GetAllPY(@chn nvarchar(100))
returns varchar(30)
as
begin


2.
declare @i int,@j int,@result varchar(100)
set @result=''
set @i=len(@chn)
set @j=1
  while @j<=@i
  begin
   set @result = @result + dbo.RmGetPY(substring(@chn,@j,1))
   set @j=@j+1
  end
return @result
end

isnumeric判断是否是数字

 

posted @ 2011-11-23 22:57  (二少)在南极  阅读(237)  评论(0编辑  收藏  举报