I found this select syntax online but not able to make it work. Please help.

I have a table that have colName as TEXT column that has special ascii characters from 0 thru 31. I an trying to do a select for this colName that will replace all special characters as '?' What am I doing wrong in this select?

select REPLACE(**colName**, 
         SUBSTRING(**colName**, 
            PATINDEX('%[^a-zA-Z0-9 ]%', 
                  **colName** collate Latin1_General_BIN), 1), '?')
from table 
WHERE PATINDEX('%[^a-zA-Z0-9 ]%', **colName** collate Latin1_General_BIN) <> 0

asked 25 Mar '13, 17:00

hm9m's gravatar image

hm9m
6344
accept rate: 0%

closed 26 Mar '13, 16:03

Mark%20Culp's gravatar image

Mark Culp
23.3k9132275

1

What database software are you using? ... I ask because the 'collate Latin1_General_BIN' syntax is not supported by SQL Anywhere ... so where did you find the syntax online.

Please refer to the SA documentation which you can find at http://dcx.sybase.com - specifically you can find the patindex function here.

(25 Mar '13, 21:47) Mark Culp

We have Adaptive Server Enterprise.

(26 Mar '13, 14:49) hm9m
Replies hidden
Comment Text Removed
3

This isn't the forum you're looking for...
droids

(26 Mar '13, 15:41) Breck Carter
1

Be careful: The Empire HANA Strikes Back...

(27 Mar '13, 12:18) Volker Barth

The question has been closed for the following reason "Question is off-topic or not relevant" by Mark Culp 26 Mar '13, 16:03


Take a look at my answer to a similar question.

permanent link

answered 25 Mar '13, 21:51

Mark%20Culp's gravatar image

Mark Culp
23.3k9132275
accept rate: 40%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×51
×12

question asked: 25 Mar '13, 17:00

question was seen: 3,606 times

last updated: 27 Mar '13, 12:18