[dbo].[ExtractNumericCharacters]
create function [dbo].[ExtractNumericCharacters]
(
@inString nvarchar(max)
)
returns nvarchar(max)
as
begin
if( dbo.IsNullOrWhiteSpace( @inString ) = 1 )
begin
return null
end
declare @indexOfNumeric int
set @indexOfNumeric = patindex('%[^0-9]%', @inString)
begin
while @indexOfNumeric > 0
begin
set @inString = stuff(@inString, @indexOfNumeric, 1, '' )
set @indexOfNumeric = patindex('%[^0-9]%', @inString )
end
end
return @inString
end
GO
GRANT EXECUTE ON [dbo].[ExtractNumericCharacters] TO [MssExec]
GO