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