set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER FUNCTION [dbo].[GET_NUMBER](@S VARCHAR(100))RETURNS VARCHAR(100)ASBEGINWHILE PATINDEX('%[^0-9]%',@S) > 0BEGINset @s=stuff(@s,patindex('%[^0-9]%',@s),1,'')ENDRETURN @SEND
select dbo.GET_NUMBER('你好111犊子')
结果:111