现在的位置: 首页 > 综合 > 正文

SQL字符串中取字母及数字的两个自定义函数(收藏)

2012年09月12日 ⁄ 综合 ⁄ 共 593字 ⁄ 字号 评论关闭

 Code

GO

/*
     create 2008-11-26
    功能:获取字符串中的字母
 
*/
create function dbo.F_Get_Number (@S varchar(100))
returns int
AS
begin
    
while PATINDEX('%[^0-9]%',@S)>0
          
begin
                
set @s=stuff(@s,patindex('%[^0-9]%',@s),1,'')
          
end
    
return cast(@S as int)
end
--测试
--
-select  dbo.F_Get_Number('测试AB3C123AB5C')

GO

抱歉!评论已关闭.