日期:2014-05-17 浏览次数:20713 次
-- 建函数
create function dbo.fn001
(@x varchar(30))
returns varchar(30)
as
begin
declare @y varchar(30),@i int
select @i=1
while(@i<=len(@x))
begin
select @y=isnull(@y,'')+case when ascii(substring(@x,@i,1)) between 48 and 57 then ''
else substring(@x,@i,1) end
select @i=@i+1
end
return @y
end
-- 测试
declare @x varchar(30)
select @x='编码0String822101100'
select @x 'x1',dbo.fn001(@x) 'x2'
/*
x1 x2
------------------------------ ------------------------------
编码0String822101100 编码String
(1 row(s) affected)
*/