Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to eliminate ASCII values from a table and contain ONLY alpha numeric values (a-z, A-Z and 0-9 and space)

$
0
0

Hi,

   I have a table which has 10 columns and these 10 columns has alpha numeric and special characters (ascii values) - My client said all the column should have ONLY alpha numeric values.

Can you please help me for this? I am not sure how to eliminate ASCII values from alpha numeric values..

I have a function as below

CREATE FUNCTION [dbo].[fn_RemoveSplChars] (@s VARCHAR(256)) 
RETURNS VARCHAR(256)
BEGIN
   IF @s IS NULL
      RETURN NULL
   DECLARE @p INT
   SET @p = 0
   WHILE @p <= 127 
   BEGIN      
      IF @p < 32 OR @p BETWEEN 33 AND 47 OR @p BETWEEN 58 AND 64 OR @p BETWEEN 91 AND 96  OR @p > 122
 SET @s = REPLACE(@s, CHAR(@p), '')
      SET @p = @p + 1
    END
   RETURN @s
END

But can you please tell me how to use this function to retrieve all the columns instead of a single column?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>