create function [dbo].[myfn_GetBeginFive](@str varchar(50)) 
returns bit
as
begin

 declare @r bit@index int@temp varchar(2),@count int
 set @r = 0
 set @index = 1 
 set @count=len(@str)
 set @temp = ''
 while @index < @count
 begin
  set @temp = substring(@str,@index,1)
  if '1234567890' like '%'+@temp+'%'
  begin
   if @temp='5'
   begin
     set @r=1
    end
    break
  end
  else
   set @index=@index+1
  end
 return @r
end

--执行函数,显示结果为 

--select '数字5开头' as 结果 where  dbo.[myfn_GetBeginFive]('HB5979uiu') = 1

GO

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案