Do you know any easy way to remove (or replace) all non alphanumeric characters from varchar variable in Mysql?
something like String\'s replaceAll(\"[^a-zA-Z0-9]\",
For MSSQL I have committed something like this:
CREATE FUNCTION removeNonAlphaNum(@p_zthes VARCHAR(255))
RETURNS varchar(255)
AS
BEGIN
DECLARE @v_bad_char_index INT;
DECLARE @v_bad_char VARCHAR(1);
DECLARE @v_res VARCHAR(255);
SET @v_res = @p_zthes;
SET @v_bad_char_index = patindex('%[^a-zA-Z0-9]%', @p_zthes)
WHILE (@v_bad_char_index > 0)
BEGIN
SET @v_bad_char = SUBSTRING(@p_zthes, @v_bad_char_index, 1);
SET @v_res = REPLACE(@v_res, @v_bad_char, 'O');
SET @v_bad_char_index = patindex('%[^a-zA-Z0-9]%', @v_res )
END
return @v_res;
END
(but I am poor SQL programmer, so there probably exist some nicer solutions)