SQL SERVER 提取字符串中数字

CREATE FUNCTION [dbo].[GET_NUMBER] (@S VARCHAR(100))
RETURNS VARCHAR(100)
AS
BEGIN
     WHILE PATINDEX('%[^0-9\\.\\^0-9]%', @S) > 0
    BEGIN
    SET @S = STUFF(@S, PATINDEX('%[^0-9\\.\\^0-9]%', @S), 1, '');
    END;
    RETURN @S;
END

 

 

PATINDEX用法详细推荐

https://www.cnblogs.com/accumulater/p/7250983.html

posted @ 2020-08-12 09:23  yongqi-911  阅读(2135)  评论(0编辑  收藏  举报