0

Question - Can Char() be set to a range/set of ASCII codes like 32 through 44?

I want to run a query that would do what this attempts to do.

SELECT REPLACE([COLUMN],CHAR(32-44,'-')
FROM TABLE 

but I this does not work. My reason is readability/geekiness and to shorten what is either a 15 replace nest deep query or creating a new table with 15 values.

weewa
  • 125
  • 3
  • 4
  • 14
  • How about using [regexp](http://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql) ? – bonCodigo Nov 20 '12 at 21:24
  • will look into it. Was looking at `PATINDEX` but to clarify I am trying to replace all special characters with `-` without nesting replace or making a table to reference. – weewa Nov 20 '12 at 21:31
  • `REPLACE([COLUMN],CHAR(32|33|34|35|36|...,'-')` works up to 15 values, on the 16th it breaks. On 15 results. Ran again on ~million results and it began to fail around 50 – weewa Nov 20 '12 at 21:42
  • The question would be, WHAT IF it goes beyond 16.....? – bonCodigo Nov 20 '12 at 21:45
  • read my comment update, poses new question! – weewa Nov 20 '12 at 21:47
  • 1
    Have you looked at CLR? You can easily create an inline function that will do what you are asking. – James L. Nov 21 '12 at 00:18
  • yes, that is how I would implement this but I just wanted to see if there was anyway of making my initial question work. – weewa Nov 21 '12 at 13:11

1 Answers1

0

N/A - there are many ways to achieve the end results but it does not look possible to select a range of numbers for ASCII characters.

weewa
  • 125
  • 3
  • 4
  • 14