1 CREATE function GetNumberChar(@col varchar(100))
2 returns varchar(20)
3 as
4 begin
5 declare @len int,@i int,@rtn varchar(20)
6 set @rtn=''
7 set @len=len(@col)
8 set @i=1
9 while @i <=@len
10 begin
11 if isnumeric(substring(@col,@i,1))=1
12 begin
13 set @rtn=@rtn+substring(@col,@i,1)
14 end
15 set @i=@i+1
16 end
17
18 if @rtn = ''
19 set @rtn='0'
20
21 return @rtn
22
23 end
24
25
26
27
28
29
30
31
32
33
2 returns varchar(20)
3 as
4 begin
5 declare @len int,@i int,@rtn varchar(20)
6 set @rtn=''
7 set @len=len(@col)
8 set @i=1
9 while @i <=@len
10 begin
11 if isnumeric(substring(@col,@i,1))=1
12 begin
13 set @rtn=@rtn+substring(@col,@i,1)
14 end
15 set @i=@i+1
16 end
17
18 if @rtn = ''
19 set @rtn='0'
20
21 return @rtn
22
23 end
24
25
26
27
28
29
30
31
32
33