SQL字符串中取字母及數字的兩個自定義函數

SQL字符串中取字母及數字的兩個自定義函數,第1張

SQL字符串中取字母及數字的兩個自定義函數,第2張


create function dbo . f _ get _ str(@ s varchar(100))
return varchar(100)
as
begin
while patindex('%[^a-z]%',@s)>0
begin
set @s=stuff(@s,patindex('%[^a-z]%',@s),1,')
end
return @ s
end
go
-test
select dboF_Get_STR ('test。大提示考ABC 123 ABC ')[/br 2008-11-26
函數:獲取字母
*/
創建函數DBO。f _ get _ number(@ svarchar(100))
return int
as[/br]begin
while patindex('%[^0-9]%',@s)>0
begin
set @s=stuff(@s,patindex('%[^0-9]%',@s),1,')
end
return cast(@ s as int)
-test
-select dbo . f _ get _ number(' test ab 3c 123 ab 5c ')[/br/

位律師廻複

生活常識_百科知識_各類知識大全»SQL字符串中取字母及數字的兩個自定義函數

0條評論

    發表評論

    提供最優質的資源集郃

    立即查看了解詳情