Tech
How to extract alpha or numbers from a string within a SELECT statement WITHOUT a function call
On December 11, 2021 by MortheI am using the following SQL to create a function to strip out characters or numbers. CREATE FUNCTION [dbo].[fn_StripCharacters] ( @String NVARCHAR(MAX), @MatchExpression VARCHAR(255) ) RETURNS NVARCHAR(MAX) AS BEGIN SET @MatchExpression = ‘%[‘+@MatchExpression+’]%’ WHILE PatIndex(@MatchExpression, @String) > 0 SET @String = Stuff(@String, PatIndex(@MatchExpression, @String), 1, ”) RETURN @String END I am calling it like this […]