views:

97

answers:

3
+1  Q: 

SQL Text Filtering

I want to filter out several key phrases out of a dataset. Unfortunately, the only algorithm I've been able to come up with thus far is nested replace statements, such as:

SELECT 
    REPLACE(
      REPLACE(FIELDNAME,'</u>','')
      ,'<u>','')

where FIELDNAME is raw HTML code stored in a table. As you can see, this is hideous. Any better ideas?

+3  A: 

I don't think there's a better way in TSQL.

If you've got another environment on top of the SQL layer (e.g asp.net) you might have more luck doing the filtering in that.

codeulike
In fact, I'd generally recommend this approach. It sounds like filtering certain words or phrases is a distinctly presentation concern, not the DB's job.
John Rudy
+1  A: 

Such string manipulations are best handled by CLR scalar valued functions.

Remus Rusanu
+1  A: 
RBarryYoung