日期:2014-05-16 浏览次数:20639 次
CREATE FUNCTION DBO.GET_NUMBER2(@S VARCHAR(100))
RETURNS VARCHAR(100)
AS
BEGIN
WHILE patindex('%[^0-9]%',@S) > 0
BEGIN
set @s=stuff(@s,patindex('%[^0-9]%',@s),1,'')
END
RETURN @S
END
GO
create table gshangju (dwmc nvarchar(20))
insert into gshangju values('200 ')
insert into gshangju values('2 01')
insert into gshangju values(' 205')
insert into gshangju values(' 6 3')
select DBO.GET_NUMBER2(dwmc)
from gshangju
/*
200
201
205
63
*/