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

Finding Characters using LIKE and Wildcard...Problems

$
0
0

I need to clean up a database of a client now that they are using a new program. Some characters are not allowed as a Key field of their inventory database, such as $,#,space, etc. So they have a lot of records with a Key field like "1.25" GAUGE", etc.

I am using the statement SELECT * from ICITEM where LIKE(citemno,"%#%') to isolate them.

for example, to find all records that have a # in the Key field.

Everything is working except for 2 instances:

First, no spaces are allowed in the Key field, but when I do the search:

SELECT * from ICITEM where LIKE(citemno,"% %')

It not only return records with a space inthe Key, but other records that do not have a space in the key (unless it is a trailing space I can't see).

Even more problematic is that no apostrophe's are allowed (" ' ")

I can't even construct an SQL statement with this, because when I do :

SELECT * from ICITEM where LIKE(citemno,"%'%') it thinks that the apostrophe is delimiting my SQL statement rather than the search key I want to look for.

Once I isolate them, I'll make a separate table out of them. Then I'll need to create a 2nd column with the new Item Numbers. Any ideas how I can do a find and replace batch statement so that whenever it sees a #, for example, I can replace it with a phrase like "NUM"

Much thanks

Bill Chicago, IL


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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