When I try to run the following function on Sybase ASE 15.7, it just spins indefinitely. Each component of the function seems to act as expected independently. This is simply a mechanism to strip all non-numeric characters from a string. Any and all thoughts appreciated.
create function dbo.mdsudf_just_digits(@str varchar(64))
returns varchar(64)
as
begin
while patindex('%[^0-9]%', @str) > 0
set @str = stuff(@str, patindex('%[^0-9]%', @str), 1, '')
return @str
end
-- A typical invocation would be like so:
select dbo.mdsudf_just_digits('hello123there456')
```